//Dave Bunnell //CMPSC Midterm: extra credit //This version uses a function to generate random colors in rgb for each new circle //The distance of the mouse from the center determines the size of the circles //A right button press freezes the current pattern and a left press returns it to the loop void setup() //setup establishes the screen size, background color of black, and makes the while loop's output move at a slow framerate. { size(900,900); //any size plugged in here will work smooth(); background(0); frameRate(1); } void draw() { float w=width; //code below stops and starts the circle pattern based on button presses if (mouseButton==RIGHT) w=0; if (mouseButton==LEFT) w=width; //this uses mouse location to determine size of the ellipses float d=dist(width/2,height/2,mouseX,mouseY); float circSize=d/5; while (w>0) { fillColor(); //calls the function that sets the fill color ellipse(width/2,height/2,w,w); w=w-circSize; }//end of the while loop }//end of draw method //a function to change the fill colors randomly void fillColor() { float r=random(255); float g=random(255); float b=random(255); fill(r,g,b); }