int numCircles = 60; // number of circles Circle[] theCircles = new Circle[numCircles]; void setup() { size(500,400); smooth(); // anti-alias noStroke(); // no outlines frameRate(30); for (int i=0; i < numCircles; i++) { theCircles[i] = new Circle(); } } void draw() { background(255); for (int i=0; i < numCircles; i++) { theCircles[i].drawCircle(); // draw the circles } } class Circle { int r; int g; int b; int xpos; int ypos; int xdir; int ydir; int size; Circle() { r = int(random(255)); // random colors b = int(random(255)); g = int(random(255)); xpos = int(random(width)); // random location ypos = int(random(height)); xdir = int(random(1,7)); // random velocities ydir = int(random(1,7)); size = int(random(30,90)); // random diameter } void moveCircle() { if (xpos > width || xpos < 0) { xdir = -xdir; } if (ypos > height || ypos < 0) { ydir = -ydir; } xpos = xpos + xdir; ypos = ypos + ydir; } void drawCircle() { moveCircle(); fill (r, g, b, 128); // alpha not random! ellipse(xpos,ypos,size,size); } }