> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.RANL3z6VRVg/rev.123
 * 
 * authors: 
 *   Keith O'Hara

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



// Keith O'Hara <[email protected]>
// Mar 2012

float speed = 3;
float opacity = 128;

void setup(){
  size(400, 300);
  background(128);
  smooth();
}

void mouseMoved(){
    opacity = map(mouseX, 0, width, 255, 0);
    speed = map(mouseY, 0, height, 0.1, 10);
}

void draw() {
  randomSeed(5);
  fill(128, opacity);
  rect(-1, -1, width, height);
  float r = 5;
  int step = 25;

  for (int x = step; x < width; x += step) {
    for (int y = step; y < height; y += step) {
      pushMatrix();
      translate(x, y);
      noStroke();
      rotate(radians(random(speed)*frameCount));
      fill(255);
      ellipse(0, -1.5 * r, r, r);
      fill(0);
      ellipse(0, 1.5*r, r, r);
      stroke(196);
      line(0, -1.5 * r, 0, 1.5*r);
      popMatrix();
    }
  }
}