Saturday, 29 November 2008

Processing 101

Finally, my copy of "Processing" arrived at Waterstones today and as late as it is I sat down to have a quick play, I am very impressed.
It's astonishingly simple to get quick results.


Here is a quick example of an animated Venn type diagram:


int angle1 = 0;
int angle2 = 120;
int angle3 = 240;
int radius = 40;

void setup() {
//start the initial window.
size(400, 400);
//start animation.
frameRate(30);
smooth();
}

void draw() {

//change the position
angle1 = angle1 + 1;
angle2 = angle2 - 1;

//clear the animation
background(255);

fill(0, 0, 255, 90);
ellipse(200 + cos(radians(angle1)) * radius, 200 + sin(radians(angle1)) * radius, 150, 150);

fill(0, 255, 0, 90);
ellipse(200 + cos(radians(angle2)) * radius, 200 + sin(radians(angle2)) * radius, 150, 150);

//no animation, just redraw.
fill(255, 0, 0, 90);
ellipse(200 + cos(radians(angle3)) * radius, 200 + sin(radians(angle3)) * radius, 150, 150);

}
The Processing book looks a whole lot of fun too - it seems very comprehensive and chocked full of information. I am looking forward to delving into it during the week.

No comments: