> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://fgcs.sketchpad.cc/sp/pad/view/ro.rlF3AVhSy6U/rev.475
 * 
 * authors: 
 *   Markus Roberts
 *   Ian Cebula

 * 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, "Spray paint", created by Markus Roberts
http://fgcs.sketchpad.cc/sp/pad/view/ro.4G2e1g8BsTVI1Nc/rev.383

It changes from Red-Green-Blue color coding to Hue-Saturation-Brightness
and adds keyboard controls to set the hue.

*/

// Pressing Control-R will render this sketch.

int hue = 0;

void setup() {  // this is run once.   
    size(600, 600); 
    colorMode(HSB);
    background(0,0,128); // Medium grey; we don't care about the hue because the saturation is zero.
    smooth();
    frameRate(60);
} 

void draw() {  // this is run repeatedly.  
    if (mousePressed) {
      for (int i=0;i<10;i++) {
        // set the color to some random translucent color
        fill(hue, random(255), random(255), 20);
        noStroke();
        // pick a random point near the mouse
        int x = mouseX+random(-15,15)+random(-15,15),
            y = mouseY+random(-15,15)+random(-15,15);

        // draw a circle there
        ellipse(x,y,6,6);
      }
    }
}

void keyPressed() {
    if      (key == 'R' || key == 'r') hue = 0;
    else if (key == 'G' || key == 'g') hue = 85;
    else if (key == 'B' || key == 'b') hue = 170;
    else if (key == 'Y' || key == 'y') hue = 50;
}