Growing Circle


Open a new script and enter the code in the following code. Don’t worry about if you don’t understand all the instructions in the function blocks – a few more new concepts are being introduced here we’ll step through:

int diam = 10;
float centX, centY;

void setup() {
   size(500, 300);
   frameRate(24);
   smooth();

   background(180);
   centX = width/2;
   centY = height/2;

   stroke(0);
   strokeWeight(5);
   fill(255, 50);
}

void draw() {
   if (diam <= 400) {
   background(180); // redraw the gray background colour for each loop
   ellipse(centX, centY, diam, diam);
   diam += 10;
   }
}

Next we’ll try to add some conditions to make it shrink when it gets to 400 pixels in diameter. See Growing & Shrinking Circle


Leave a Reply

Your email address will not be published. Required fields are marked *