Modify a text file: $/x212Kousar_colorchange.pde
$/x212Kousar_colorchange.pde
// x212Kousar float x = 600; float y = 300; float xSpeed = 20; float ySpeed = 20; int r, g, b; int count=0; void setup () { size(800, 800); reset(); } void reset() { r= (int) random(255); g= (int) random(255); b= (int) random(255); } void draw () { background(#E335C6); fill(0); text( "r to reset, q to quit", width*3/4, 20 ); // Reset every 90 frames count = count + 1; if ( (count%30) == 0 ) { reset(); } x += xSpeed; if (x > width || x < 0) { xSpeed = xSpeed * -1; } y+= ySpeed; if (y > height || y < 0) { ySpeed *= -1; } { ellipse(x, y, 200, 200); //largest circle stroke(0); //-- fill(random(255), random(255), random(255)); fill( r, g, b ); } { rect(25, 25, 100, 100); rect(200, 200, 200, 200); rect(500, 500, 200, 200); ellipse(x, y, 100, 100); //middle circle ellipse(x, y, 50, 50); //smallest circle } } void keyPressed() { if (key == 'r') { reset(); } if (key == 'q') { exit(); } }