Week 5 - Rec­u­r­s­i­o­n of Cir­c­l­e­s

by Yulong Guo
  • Show Sketch
/* @peep sketchcode */
void setup() {
size(400, 400);
background(random(255), random(255), random(255));
circle(20, 20, width, height);
}
 
void circle(float x, float y, float w, float h) {
  fill(random(255), random(255), random(255), random(255));
  noStroke();
  ellipse(x, y, w, h);
  if((random(200)<160) && (w>20 || h>20)) {
    float ix = 3;
    float iy = 3;
    w = (w-3*ix)/2;
    h = (h-3*iy)/2;
    circle(x + ix, y + iy, w, h);
    circle(x + ix + w + ix, y + iy, w, h);
    circle(x + ix, y + iy + h + iy, w, h);
    circle(x + ix + w + ix, y + iy + h + iy, w, h);
  }
}

Comments

Nobody has said anything yet.