ArrayList balls; float clickTime; float rMultiplier; color curColor; float xoffset; float nIncr; boolean controllerOver; Controller masterControl; float amp; void setup() { size(640,480); background(0); masterControl = new Controller (width-80,height-80,100,30); balls = new ArrayList(); addBall(random(0,width),random(0,height), random(20,100), color(random(0,255),random(0,255),random(0,255))); frameRate(30); rMultiplier = 3; xoffset = 5; nIncr = .01; amp = 10; smooth(); } void draw() { strokeWeight(1); background(0,0,0); stroke(255); masterControl.run(); for (int b = 0; b < balls.size(); b++) { Ball curBall = (Ball) balls.get(b); curBall.run(); } if (mousePressed == true && controllerOver == false) { fill(curColor); ellipse(mouseX,mouseY,(frameCount-clickTime)*rMultiplier,(frameCount-clickTime)*rMultiplier); } } void mousePressed() { clickTime = frameCount; curColor = color(random(0,255),random(0,255),random(0,255)); fill(curColor); } void mouseReleased() { if (controllerOver == false) { float dTime = frameCount - clickTime; addBall(mouseX,mouseY,dTime*rMultiplier,curColor); } } void addBall(float x, float y, float r, color c) { Ball curBall = new Ball(x,y,r,c); balls.add(curBall); } class Ball { float x,y,r, maxR; float n; color c; Ball (float inX, float inY, float inR, color inC) { x = inX; y = inY; maxR = inR; r = maxR; c= inC; } void run() { moveBall(); modR(); fill(c); stroke(255); strokeWeight(1); ellipse(x,y,r,r); } void moveBall() { x = (x + xoffset)%width; y = (y+genNoise())%height; } float genNoise() { n += nIncr; return ( (noise(n)-.5)*amp ); } void modR() { r = cos(n)*maxR; } }