// The current coordinates of the ball, starting at the center (in setup) float x, y; // The current color of the ball, and whether it's increasing or decreasing int gray=255, dgray=-1; // The current size of the ball, and how much it's increasing or decreasing float sz=5, dsz=0.1; void setup() { size(400,400); smooth(); noStroke(); background(0); x=width/2; y=height/2; } void draw() { fill(0,3); rect(0,0,width,height); fill(gray); ellipse(x,y,sz,sz); // Move the position by random steps in x and y x += random(-10,10); y += random(-10,10); // Increase/decrease the color, changing direction at the extremes gray += dgray; // too large or too small, go the other way if (gray <= 128) dgray = 1; else if(gray >= 255) dgray = -1; // Increase/decrease the size, changing direction at the extremes sz += dsz; // if too large or too small, go the other way if (sz <= 2 || sz >= 15) dsz = -dsz; } // START NO NOTES // code used to capture screenshots void keyReleased() { if(key == '`' && !online) save("sketch.png"); }