> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.pByO4fPxQSj/rev.313
 * 
 * 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, "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) { 
      // we give a unique rotation amount to each circle, depending
      // on which column and row the circle is located (x and y)
        if(x <= 5 && y <= 4){
            if((x+y)%2 == 0)
                fill(255);
            else
                fill(50, 50, 250);
        }else{
            if((y/2) %2 < 1){
                fill(255);
            }else{
                fill(250, 50, 50);
            }
//            fill(map(x, 0, 16, 0, 255));
        }
      draw_rotating_circle(50 + x * 20, 50 + y * 15, 12, (rot + x + y)/2);
      y = y + 1;
    }
    x = x + 1;
  }
  rot = rot + 0.05;
}