Processing: It’s totally not Flash
July 20th, 2007
I’m not one to advocate Java generally, but Processing is totally hawt. Here’s something I screwed around with today:
type=”application/x-java-applet”
archive=”/assets/2007/7/20/sketch_070719a.jar”
width=”500″ height=”500″
standby=”Loading Processing software…” > codebase=”http://java.sun.com/update/1.4.2/jinstall-1_4_2_12-windows-i586.cab”
width=”500″ height=”500″
standby=”Loading Processing software…” > value=”/assets/2007/7/20/sketch_070719a.jar” />
archive=”/assets/2007/7/20/sketch_070719a.jar”
width=”500″ height=”500″
standby=”Loading Processing software…” > codebase=”http://java.sun.com/update/1.4.2/jinstall-1_4_2_12-windows-i586.cab”
width=”500″ height=”500″
standby=”Loading Processing software…” > value=”/assets/2007/7/20/sketch_070719a.jar” />
Ball[] myBalls; void setup() { size(500,500); frameRate(25); myBalls = new Ball[300]; for (int i = 0; i < 300; i++) { myBalls[i] = new Ball(); myBalls[i].x = random(0, 500); myBalls[i].y = random(0, 500); myBalls[i].r = random(0, 10); myBalls[i].xv = random(-5, 5); myBalls[i].yv = random(-5, 5); myBalls[i].mycolor = int(random(0, 100)); myBalls[i].myseed = int(random(25,100)); } } void draw() { background(0); for (int i = 0; i < 300; i++) { myBalls[i].run(); } } class Ball { float x; //X acis centroid float y; //Y axis centroid\ float r; // Radius float xv; //X axis velocity float yv; //Y axis velocity int mycolor; int myseed; int counter; void run() { drawShape(); x += xv; y += yv; yv += 0.4; if(x < 0 || x > width) { xv = -xv; } else if(y < 0 || y > height) { yv = -1.1 * yv; } if(counter % myseed == 0) { xv = random(-5,5); yv = random(-5,5); } counter++; } void drawShape() { smooth(); ellipseMode(CENTER_RADIUS); noStroke(); fill(mycolor); ellipse(x,y,r,r); } }
You can download it here: sketch_070719a
