> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://bard117s14.sketchpad.cc/sp/pad/view/ro.nv11uqB6IrO/rev.2
 * 
 * authors: 
 *   keith mackie

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



float x=200;
float y=200;
float xstep=0;
float ystep=0;

void setup() {

  ystep=random(-10, 10);
  xstep=random(-10, 10);

  size(600, 600);
  smooth();
  background(255);
  //mouth
  fill(187, 201, 250);
  stroke(0);
  strokeWeight(7);
  rect(40, 450, 500, 30);
  //eyes
  fill(250, 246, 169);
  stroke(0);
  strokeWeight(7);
  rect(100, 200, 190, 200);
  rect(310, 200, 190, 200);
  //teeth
  stroke(0);
  strokeWeight(7);
  line(60, 450, 60, 480);
  line(180, 450, 180, 480);
  line(200, 450, 200, 480);
  line(80, 450, 80, 480);
  line(100, 450, 100, 480);
  line(220, 450, 220, 480);
  line(120, 450, 120, 480);
  line(240, 450, 240, 480);
  line(140, 450, 140, 480);
  line(260, 450, 260, 480);
  line(160, 450, 160, 480);
  line(280, 450, 280, 480);
  line(300, 450, 300, 480);
  line(320, 450, 320, 480);
  line(340, 450, 340, 480);
  line(360, 450, 360, 480);
  line(380, 450, 380, 480);
  line(400, 450, 400, 480);
  line(420, 450, 420, 480);
  line(440, 450, 440, 480);
  line(460, 450, 460, 480);
  line(480, 450, 480, 480);
  line(500, 450, 500, 480);
  line(520, 450, 520, 480);
  //pupils
  stroke(0);
  strokeWeight(5);
  point(260, 300);
  point(340, 300);
  point(250, 300);
  point(350, 300);
  point(350, 290);
  point(340, 290);
  point(260, 290);
  point(250, 290);
  //eyebrows
  strokeWeight(15);
  line(150, 120, 300, 220);
  line(300, 220, 450, 120);
  fill(255, 0, 0);
  //cheeks
  strokeWeight(4);
  ellipse(40, 400, 30, 30);
  ellipse(560, 400, 30, 30);
  fill(0);
  rect(0, 0, 600, 100);
}




void draw () {


  //mouth
  fill(187, 201, 250);
  stroke(0);
  strokeWeight(7);
  rect(40, 450, 500, 30);
  //eyeshadow
  fill(0); 
  rect(80, 190, 440, 240);
  //eyes
  fill(250, 246, 169);
  stroke(0);
  strokeWeight(7);
  rect(100, 200, 190, 200);
  rect(310, 200, 190, 200);
  //teeth
  stroke(0);
  strokeWeight(7);
  line(60, 450, 60, 480);
  line(180, 450, 180, 480);
  line(200, 450, 200, 480);
  line(80, 450, 80, 480);
  line(100, 450, 100, 480);
  line(220, 450, 220, 480);
  line(120, 450, 120, 480);
  line(240, 450, 240, 480);
  line(140, 450, 140, 480);
  line(260, 450, 260, 480);
  line(160, 450, 160, 480);
  line(280, 450, 280, 480);
  line(300, 450, 300, 480);
  line(320, 450, 320, 480);
  line(340, 450, 340, 480);
  line(360, 450, 360, 480);
  line(380, 450, 380, 480);
  line(400, 450, 400, 480);
  line(420, 450, 420, 480);
  line(440, 450, 440, 480);
  line(460, 450, 460, 480);
  line(480, 450, 480, 480);
  line(500, 450, 500, 480);
  line(520, 450, 520, 480);

  //eyebrows
  strokeWeight(15);
  line(150, 120, 300, 220);
  line(300, 220, 450, 120);
  fill(255, 0, 0);
  //cheeks
  strokeWeight(4);
  ellipse(40, 400, 30, 30);
  ellipse(560, 400, 30, 30);
  //hat
  fill(0);
  rect(0, 0, 600, 100);

  fill(x, y, mouseX);
  stroke(0);
  strokeWeight(7);
  rect(100, 200, 190, 200);
  rect(310, 200, 190, 200);

  x=x+xstep;
  y=y+ystep;

  if (x>=290) {
    xstep=-1*xstep;
  }
  else if (x<=100) {
    xstep=-1*xstep;
  }
  if (y>=400) {
    ystep=-1*ystep;
  }
  else if (y<=200) {
    ystep=-1*ystep;
  }

  //floaing ball
  fill(mouseX, mouseY, random(255-8));
  rect(x, y, 20, 20);
  rect(x+200, y, 20, 20);

  x=x+xstep;
  y=y+ystep;

  if (x>=290) {
    xstep=-1*xstep;
  }
  else if (x<=100) {
    xstep=-1*xstep;
  }
  if (y>=400) {
    ystep=-1*ystep;
  }
  else if (y<=200) {
    ystep=-1*ystep;
  }
}

void keyPressed() {
  background(255);
}

void mousePressed(){
 background(random(255,0));
  //mouth
  fill(mouseX, 201, 250);
  stroke(0);
  strokeWeight(7);
  rect(40, 450, 500, 30);
  //eyes
  fill(250, mouseY, 169);
  stroke(0);
  strokeWeight(7);
  rect(100, 200, 190, 200);
  rect(310, 200, 190, 200);
  //teeth
  stroke(255);
  strokeWeight(7);
  line(60, 450, 60, 480);
  line(180, 450, 180, 480);
  line(200, 450, 200, 480);
  line(80, 450, 80, 480);
  line(100, 450, 100, 480);
  line(220, 450, 220, 480);
  line(120, 450, 120, 480);
  line(240, 450, 240, 480);
  line(140, 450, 140, 480);
  line(260, 450, 260, 480);
  line(160, 450, 160, 480);
  line(280, 450, 280, 480);
  line(300, 450, 300, 480);
  line(320, 450, 320, 480);
  line(340, 450, 340, 480);
  line(360, 450, 360, 480);
  line(380, 450, 380, 480);
  line(400, 450, 400, 480);
  line(420, 450, 420, 480);
  line(440, 450, 440, 480);
  line(460, 450, 460, 480);
  line(480, 450, 480, 480);
  line(500, 450, 500, 480);
  line(520, 450, 520, 480);
  
  //eyebrows
  strokeWeight(15);
  line(150, 120, 300, 220);
  line(300, 220, 450, 120);
  fill(255, 0, 0);
  //cheeks
  strokeWeight(4);
  ellipse(40, 400, 30, 30);
  ellipse(560, 400, 30, 30);
  fill(random(255,0),255,mouseX);
  rect(0, 0, 600, 100);
}

void mouseDragged() {
  smooth();
  stroke(random(255-200), mouseX, mouseY);
  strokeWeight(5);
  line(width-mouseX, mouseY, width-pmouseX, pmouseY);
  stroke(mouseX, random(200-100), mouseY);
  line(mouseX, mouseY, pmouseX, pmouseY);

 background(random(255,0));
  //mouth
  fill(mouseX, 201, 250);
  stroke(0);
  strokeWeight(7);
  rect(40, 450, 500, 30);
  //eyes
  fill(250, mouseY, 169);
  stroke(0);
  strokeWeight(7);
  rect(100, 200, 190, 200);
  rect(310, 200, 190, 200);
  //teeth
  stroke(255);
  strokeWeight(7);
  line(60, 450, 60, 480);
  line(180, 450, 180, 480);
  line(200, 450, 200, 480);
  line(80, 450, 80, 480);
  line(100, 450, 100, 480);
  line(220, 450, 220, 480);
  line(120, 450, 120, 480);
  line(240, 450, 240, 480);
  line(140, 450, 140, 480);
  line(260, 450, 260, 480);
  line(160, 450, 160, 480);
  line(280, 450, 280, 480);
  line(300, 450, 300, 480);
  line(320, 450, 320, 480);
  line(340, 450, 340, 480);
  line(360, 450, 360, 480);
  line(380, 450, 380, 480);
  line(400, 450, 400, 480);
  line(420, 450, 420, 480);
  line(440, 450, 440, 480);
  line(460, 450, 460, 480);
  line(480, 450, 480, 480);
  line(500, 450, 500, 480);
  line(520, 450, 520, 480);
  
  //eyebrows
  strokeWeight(15);
  line(150, 120, 300, 220);
  line(300, 220, 450, 120);
  fill(255, 0, 0);
  //cheeks
  strokeWeight(4);
  ellipse(40, 400, 30, 30);
  ellipse(560, 400, 30, 30);
  fill(random(255,0),255,mouseX);
  rect(0, 0, 600, 100);
}