Circle Of Circles Animated


  int nbr_circles = 24;
  
  void setup()
  {
    size(200,200);
    smooth();
    frameRate(24);
  }
  
  void draw()
  {
    background(255);
  
    nbr_circles = 18 + (frameCount % 200);
  
    float lg_diam = width * .85;
    float lg_rad = lg_diam / 2;
    float lg_circ = PI * lg_diam;
    float sm_diam = (lg_circ / nbr_circles);
    float cx = width/2.0;
    float cy = height/2.0;
    
    fill(0);
    for (int i = 1; i <= nbr_circles; ++i) {
      float angle = i * TWO_PI / nbr_circles;
      float x = cx + cos(angle) * lg_rad;
      float y = cy + sin(angle) * lg_rad;
      ellipse(x, y, sm_diam, sm_diam);
    }
  }
  // END