Processing Test 2 - Fluidity
Processing Test 1 (Fluidity) from Jon Gos on Vimeo.
Processing Test 1 (Fluidity) from Jon Gos on Vimeo.
Ah, I’ve been quite out of touch with happenings in the design world. Today I just discovered the long-awaited Processing book had been published!
You will find a sketch of little fish in the Synthesis section of the book. I made the Pond sketch for Processing about 4 or 5 years ago. Time flies… it’s nice to find it again in the book.
View Processing applet and code »
This code simulates throwing a piece of card on a surface. It’s gathering dust in my folder, so I thought I should clean it up a bit and share it.
Made with Processing.

While playing around with the magnetosphere code, I found myself wondering what it would look like if I restricted the movement of the particles to the surface of a sphere. Well, it ended up looking like I thought it would. Pretty, but ultimately not an improvement. It looked a bit like the magnetic structure bucky ball pieces from a couple months ago.
On a whim, I added a new vector which would cause the particles to swirl around the center of the sphere along a coded equator. I started to see hints of nice turbulence swirls so I kept at it. To help emphasize this effect, I modified the rotational vector to have three peaks so as you travel from the north pole to the south, you would pass through three bands of rotation. I also added a perlin noise vector to make the movements seem even more chaotic. Here is the most recent video.

Here is the result from the first go.
Turbulence from flight404 on Vimeo.
The brighter dots represent the positions of the main particles. In order to make it look a bit cloudier, I started using the midpoints between nearby points. If two points have a distance of less than 100, I draw a fuzzy texture between them whose size and alpha are inversely proportional to the distance. So as the distance between two particles decreases, the fuzzy texture gets larger and brigther. Because of this, the ‘clouds’ can appear and disappear as the main particles drift about.
Here is another version where I am using simple gradient ellipses.

Turbulence, cont. from flight404 on Vimeo.
I tried sticking the textured earth sphere in the middle of this mess of particles but the effect was a bit cheese. Maybe I will come back to it if I feel like pushing this towards a more realistic cloud layer, but Im thinking I will stick with the simplicity of the white on black for a while longer.
Let’s try this again. If you’re reading this on Processing Blogs or via its feed, then everything should be working.
Instead of Feedwordpress and Planet Planet put together with sticky tape and glue, I’m using the better documented Planet Venus and WP-Venus so our archives are maintained.
If you ever need to run a site similar to Processing Blogs and your web host can run python then I definitely recommend Planet or Planet Venus as the solution. WP-Venus complained a little bit when I converted from Feedwordpress, but it looks good so far: hopefully the archives will be worth the effort.
Processing workshop at Lovebytes 2007, Sheffield, UK, by David Muth
Arduino Workshop with Massimo Banzi, Lisbon, Portugal (Atmosferas)Info: www.atmosferas.net/en/index.htm
Ben Fry is presenting at O’Reilly’s OSCON 2007!
Processing workshop by David Muth at this year’s Takeaway Festival at the Science Museum’s Dana Centre, London, UK
Sometimes in Processing you want to do something with a certain rhythm, and you don’t feel like writing something like this:
long m = millis();
void draw() {
if (millis() - m > 1000) {
m = millis();
println("wow!");
}
}
What you really want is a true timer, something that calls a part of your program every n milliseconds.
Well, Java has just such a Timer and it’s not all that hard to use. If you look at the class (link), you’ll see that you have just a few methods that deal with setting how often your timer needs to go off, cancelling your timer, and maybe one or two other things. The hard part (which isn’t really all that hard if you read understood my recent post about Polymorphism) is actually setting up the Timer using the extends syntax.
Bascially, you have to create some class that is going to be called periodically, and then inform Java that this class is going to act like a TimerTask. This is the role of the « extends » keyword. The syntax is as follows:
class Beat extends TimerTask {
Timer timer;
Beat() {
timer = new Timer();
timer.scheduleAtFixedRate(this, 0, 1000);
}
// careful! something's missing here
}
If you try to run the following code, Processing/Java will yell at you. Hey you idiot! You forgot to tell me what I’m supposed to do every 1000 milliseconds! A TimerTask needs to implement a method that will be called whenever the Timer fires. Since we’ve extended the TimerTask class, Java knows that this object has to contain a method named « run() » in order to work. It knows as such because when you pushed the “play” button, it went to look inside the definition of the abstract class « TimerTask », where it is explained that all TimerTask objects have to include a « run() » method.
Here’s the completed class:
class Beat extends TimerTask {
Timer timer;
Beat() {
timer = new Timer();
timer.scheduleAtFixedRate(this, 0, 1000);
}
void run() {
// do something here
}
}
Now that the run() method has been declared, the rest is easy to explain. The « sheduleAtFixedRate » method is pretty easy to understand. If you write it this way, it just means « after waiting 0 milliseconds before starting, call « this » object’s run() method every 1000 milliseconds ».
Here’s a dopey little animation to show you how it might work:
Beat beat;
void setup() {
smooth();
beat = new Beat();
}
void draw() {
beat.draw();
}
void mousePressed() {
beat.die();
}
class Beat extends TimerTask {
Timer timer;
int alfa = 0;
int speed = 5;
Beat() {
timer = new Timer();
timer.scheduleAtFixedRate(this, 0, 1000);
}
void run() {
alfa = 255;
}
void die() {
timer.cancel();
}
void draw() {
background(255);
noStroke();
fill(0,alfa);
ellipse(width/2, height/2, 10, 10);
alfa = max(alfa-speed, 0);
}
}
The same idea, with prisms, uh… rotating.
Images are acquired with a webcam and mapped to a set of 3D prisms in real time.
Their heights are distorted by a Perlin noise, but also correspond to the brightness of the mapped pixel.
Made with Processing.org (more)
Author: krahd
Keywords: processing real time webcam perlin noise
Added: September 10, 2007
Via Slashdot who got it from tshb, here’s a fascinating paper by Daniel E. Holcomb, Wayne P. Burleson, and Kevin Fu (University of Massachusetts) on accessing the physical properties of digital circuits for both the generation of random numbers and the fingerprinting of individual circuits . The paper is entitled Initial SRAM State as a Fingerprint and Source of True Random Numbers for RFID Tags (link).
I always wonder why people are so obsessed with this idea of « true » random numbers. It’s as if computer science, in its vain lust for purity — i.e. to rid the circuitry of « noise » through the abstraction of physical substrates —, had somehow actually succeeded in achieving a purely unphysical world in which circuitry could conduct itself outside of the constraints of base material imperfection.
Ironically, the dream of true imperfection seems troubled by the same science fiction, only on the other side of the dialectic. For example, in John Maeda’s Design by Numbers, we find a similar disdain for the artificial nature of random numbers, and a gentle prod to new coders to avoid its siren song as much as possible :
The amateur may be tempted by the cheap thrills of randomness. Random numbers, noise, stochastics, or whatever you want to call the complete lack of control that serves as the roots of techno-styled graphics, is a form of profanity that you should generally avoid. But in many ways, resistance may prove futile because complete control of a complex computational process is still something of a faraway goal and the allure of randomness can be overpowering. My personal philosophy has been that if you are going to use randomness, you should at least know where it comes from. Design by Numbers, p.247
I love Maeda’s pragmatism : hey Kid, before you play with that dirty code, you should at least know where it’s been sleeping around!
When I read that passage from Maeda’s 1999 masterpiece (yeah, that’s a big word, but come on, we’re talking about the origins of Processing here), I burst out laughing. Until then, I had avoided random numbers for pretty much the same reasons: they somehow represented sloppy, or lazy coding practices to me. But hearing someone else say it out loud immediately cured me of this folly and I immediately began throwing random numbers into pretty much anything that moved, calculated, reacted, beeped, blurped or just sat there waiting for someone to click on it. Upon learning that random numbers were the equivalent of an easy date, a vaccuous pop song, or perhaps the fatty delight of cheap fast food that you eat precisely because it is bad for you, somehow those random numbers felt all the more fun, all the more rebellious: kind of like dressing up like a punk rocker at 16 in the protected confines of your suburb (I know something about this): it’s not like you’re going to do any real damage to anything so you might as well just run with it.
But something funny happened after using these skanky random numbers for several years of guilty pleasure. Little by little I realized that I started to inuitively recognize these numbers and could even feel when my programs had shifted from one random thread to the next. I could even feel when my random numbers had moved from one dimension to two or three dimensions of calculation. Since most of the random numbers I used were of the really cheap kind (i.e. nothing like the relatively effective sort, such as the Mersenne Twister), ultimately I was coming to know (fairly well) the feel of the random number, even if its seed always departed from a new (and therefore different) point. It’s somewhat silly, I know, but in one project in particular — my Concrescence algorithmic cinema platform —, I actually stuck with cheap random numbers precisely because after so many years of milking those numbers I ended up finding what I considered their sweet spot of expression.
What I’m talking about, ultimately, is form; and it is this aspect which brings me back to the aforementioned paper. While the specifics may change, the forms they reveal are anything but immaterial. And just as in any process bound by what I like to call the process of algorithmic « physicalization », the effect is reversible. When I said that I felt my random numbers, I meant it quite literally as I was generating images and sounds based on user touch, and that material behavior became easy to recognize over time. You can understand a lot about the underlying physical apparatus that runs the software simply through the observation of its output. But the reverse is also true : by fiddling with the physical aspect of the cell you can impregnate digital circuits with interrestic behaviors.
I love the diagram on page 5 that follows this amazing quote: « By descending below the logical level of abstraction, and considering RAM to be a physical fingerprint, a wealth of information is found. » The diagram shows the precise point at which the SRAM cell generates both its fingerprint and « true » random numbers :

CmdrTaco expressed « surprise » at this double quality of {identification} and {randomness}. But when you get down to it, both states are by-products of the same nature of circuit being a physical device. To simplify our terminology, the circuit brings with it what so many today are calling « analog » world, although I find this term unfortunate because it merely exists as the rediscovered sibling of « digital ». I far prefer the idea of a process of physicalisation that poses the analog world as neither a given nor a goal, but instead an internal quality of hybrid processes.
The hybrid nature of repurposing digitally the physical circuit already sitting in the computer you’re using to read this post, is an exciting prospect, and if pushed to its extreme could even re-write the mythe de la mite (the myth of the moth in the machine). When Grace Murray Hopper pulled that famous moth out of the machine and taped it into her notebook, the joke was of course that the idea of a « bug » in the machine had suddenly found a very litteral instance. But my reading of this myth went more into nature of interfaces, and the fact that the moth had actually crashed the machines precisely because it had interacted with the computer not via its terminal (or punch-card, or whatever), but instead directly via it’s modular circuitry. But in fact, technology such as random number generators that use the physicality of the circuit to determine a digital transduction, operate precisely at this level of « direct » interaction, and do so perfectly fine without crashing anything. And of course most transducers do the same day-in, day-out without causing any serious harm, and ultimately, as the referenced paper show, can be folded back into the digital nature of the circuit without much worry.
Images are acquired with a webcam and mapped to a set of 3D spheres in real time.
Their radius are distorted by a Perlin noise, while the z-values correspond to the brightness of the mapped pixel.
Made with Processing.org
Author: krahd
Keywords: processing real time webcam perlin noise
Added: September 10, 2007
if you should ever have to use an nvidia 8800 gtx under ubuntu feisty:
download the latest nvidia linux driver and install it like this (don’t download the beta drivers). that does not work after rebooting anymore.
open /etc/modprobe.d/lrm-video and comment out some lines:
## Make nvidia/nvidia_legacy and fglrx use /sbin/lrm-video to load
#install fglrx /sbin/lrm-video fglrx $CMDLINE_OPTS
install nvidia /sbin/lrm-video nvidia $CMDLINE_OPTS
#install nvidia_legacy /sbin/lrm-video nvidia_legacy $CMDLINE_OPTS
#install nvidia_new /sbin/lrm-video nvidia_new $CMDLINE_OPTS
open /etc/default/linux-restricted-modules-common and disable the modules fglrx, nvidia_legacy, nvidia_new
add the following lines to /etc/X11/xorg.conf
Section “Extensions”
Option “Composite” “Enable”
EndSection