Ball[] balls; int numBalls = 1500; int currentBall = 0; float phi = (sqrt(5)+1)/2; // Calculate Phi void setup () { size(500, 300); background(0); smooth(); noStroke(); balls = new Ball[numBalls]; // Create the array for (int i = 0; i < numBalls; i++) { balls[i] = new Ball(); // Create each ball } } void draw() { fill(0, 2); rect(0, 0, width, height); fill (255); for (int i = 0; i < numBalls; i++) { balls[i].display(); } } //Click to create a new Ball void mousePressed() { balls[currentBall].start(mouseX, mouseY, 0.1); currentBall++; if (currentBall >= numBalls) { currentBall = 0; } } // Ball Class class Ball { float sx, sy; float speed = 0.05; boolean on = false; float x; float y; float angle = 0.0; void start(float xpos, float ypos, float spd) { sx = xpos; sy = ypos; speed = spd; on = true; } void display() { if (on == true) { angle += speed; //Update the angle float sinval = sin(angle); float cosval = cos(angle); float x = sinval * (pow(phi, (2/PI)*(angle))); float y = cosval * (pow(phi, (2/PI)*(angle))); ellipse(x + sx, y + sy, 3, 3); // Draw circle if (x > (width*2)) { on = false; angle = 0; } } } }