> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.RB$R1Lmbg1W/rev.130
 * 
 * authors: 
 *   Cody Gray

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



// This sketch builds on a prior work, "American Flag", created by Cody Gray
// http://studio.sketchpad.cc/sp/pad/view/ro.91pw6htJwSsop/rev.313



// This sketch builds on a prior work, "35. A grid of rotating objects creates a wave of rectangles", created by Fun Programming
// http://studio.sketchpad.cc/sp/pad/view/ro.9jbYMmZSsnb-v/rev.91



// Episode 35 of http://funprogramming.org at http://youtu.be/3v9YXBX8AVg

float rot = 0;

void setup() {
  size(400, 300);
  background(100, 200, 50);
  smooth();
  noStroke();
  ellipseMode(CORNER);
}
void draw_rotating_circle(float x, float y, float cir_size, float r) {
  translate(x, y);
  rotate(r);
  ellipse(0, 0, cir_size, cir_size);
  resetMatrix();
}
void draw() {
  background(100, 200, 50);

  float x = 0;
  while (x < 16) {
    float y = 0;
    while (y < 14) { 
        if(x <= 3 || x >= 12){
            fill(250, 50, 50);
        }else if(x > 5 && x <= 9 && y >= 5 && y < 9 ){
            fill(250, 50, 50);
        }else{
            fill(255);
        }
      // we give a unique rotation amount to each circle, depending
      // on which column and row the circle is located (x and y)
      draw_rotating_circle(50 + x * 20, 50 + y * 15, 12, (rot + x + y)/2);
      y = y + 1;
    }
    x = x + 1;
  }
  rot = rot + 0.05;
}