> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://bard117f12.sketchpad.cc/sp/pad/view/ro.xWWVBDrDpPo/rev.45
 * 
 * authors: 
 *   Charley Summers

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



// Charley Summers
// 9/23/12
// [email protected]
// Self Portrait II: Super Portrait

/* 
Creating a self portrait with Processing rather than Design Blocks granted me a lot more freedom.
I was able to add external images, and upon holding down the "A" key, get them to appear in a random sequence,
size and position. This would not have been possible in Design Blocks, though random colors and stroke widths
were. Having a morphing background color depentent on holding down the "D" key would also not have been possibe. 
Obviously, while working with Processing, it has taken me a lot longer to create a self portrait due both to
the length it takes to type the code out (rather than drag and drop) and the learning curve of programming 
languages.
*/

PImage mushroom;
PImage b;
PImage g;
int p;
int x;
int y;
int w;
int h;
int c1;
int c2;

void setup(){
  colorMode(HSB, 360, 100, 100);
  background (360);
  size(500, 500);
  mushroom = loadImage("/static/uploaded_resources/p.6393/mushroom.jpg");
  g = loadImage("/static/uploaded_resources/p.6393/green.jpg");
  b = loadImage("/static/uploaded_resources/p.6393/blue.jpg");
  noFill();
  smooth();
}

void draw() {
  x = int (random(0, 500));
  y = int (random(0, 500));
  w = int (random(0, 500));
  h = int (random(0, 500));
  p = int (random(1, 4));
  c1 = int (random(0, 360));
  c2 = int (random(0, 100));
  
  if(keyPressed) {
    if (key == 'a' || key == 'A') {
      if (p == 1) {
        image (mushroom, x, y, frameCount%100, frameCount%100);}
      else if (p == 2) {
        image (b, x, y, frameCount%60, frameCount%60);}
      else if (p == 3) {
        image (g, x, y, frameCount%60, frameCount %60);}
      }
   if (key == 'd' || key == 'D'){
      background(frameCount/2 % 360, 100, 100, c2);}
   if (key == 's' || key == 'S'){
     noStroke();
     fill(c1, c2, c2, c2);
     rect(x, y, w, h);
   }
    }
  }

void mouseDragged() {
  strokeWeight(frameCount%30);
  stroke(pmouseX, mouseY, 100);
  line(pmouseX, pmouseY, mouseX, mouseY);
  line(width-pmouseX, pmouseY, width-mouseX, mouseY);
}