Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/* /////////////////////////////////////////////////////////////////////////
 Athos the Boxer, made my Andreea Pop in Processing. The mouse can be moved
 left and right to move the clouds, and the sky lightly changes colours 
 depending on where the mouse is. Up and down movements control the eyebrows, 
 and the eyes will follow the mouse. Clicking the image will have Athos lightly 
 borf at you.
 
 Total Shapes: 61
 Total Shapes (with lines included): 72
 ////////////////////////////////////////////////////////////////////////// */

void setup() {
  //window size 400x400 px
  size(400, 400);
  //background colour
  background(157, 135, 135);
}

void draw() {
  //basic setup
  //framerate
  frameRate(30);
  //no outlines for shapes
  noStroke(); 
  //define the two corner points of the rect
  rectMode(CORNERS); 
  //define the center of the ellipse
  ellipseMode(CENTER);

  //bottom of dog bed
  fill(211, 179, 179);
  rect(0, 200, 400, 400);

  //top border of bed
  fill(234, 199, 199);
  rect(0, 310, 400, 340);

  //sky outside
  fill(100+mouseX*0.1, 100+mouseX*0.1, 255); 
  rect(40, 0, 180, 140);

  /* #+mouseX the number represents how far 
   away it is from the X axis, the *0.2 slows 
   the movement down to half the mouse speed */
  //cloud 1
  fill(255);
  ellipse(60+mouseX*0.3, 90, 80, 20);
  ellipse(20+mouseX*0.3, 80, 40, 40);
  ellipse(40+mouseX*0.3, 80, 30, 20);
  ellipse(10+mouseX*0.3, 90, 30, 20);
  //cloud 1 shade; duplicate cloud, but translucent
  fill(255, 255, 255, 150);
  ellipse(50+mouseX*0.3, 90, 80, 20);
  ellipse(10+mouseX*0.3, 80, 40, 40);
  ellipse(30+mouseX*0.3, 80, 30, 20);
  ellipse(mouseX*0.3, 90, 30, 20);

  //cloud 2
  fill(255);
  ellipse(120+mouseX*0.2, 30, 80, 40);
  ellipse(80+mouseX*0.2, 40, 60, 20);
  ellipse(140+mouseX*0.2, 50, 40, 20);
  //cloud 2 shade
  fill(255, 255, 255, 150);
  ellipse(110+mouseX*0.2, 30, 80, 40);
  ellipse(70+mouseX*0.2, 40, 60, 20);
  ellipse(130+mouseX*0.2, 50, 40, 20);

  //cloud 3
  fill(255);
  ellipse(10+mouseX*0.1, 130, 60, 20);
  ellipse(mouseX*0.1, 120, 60, 20);

  //window sill
  fill(234, 199, 199);
  rect(40, 130, 180, 140);

  //left curtain
  fill(152, 92, 92);
  rect(0, 0, 40, 160);
  //left curtain shade
  fill(108, 55, 55);
  triangle(30, 160, 30, 80, 40, 160);

  //right curtain
  fill(152, 92, 92);
  rect(180, 0, 260, 160);
  //right curtain shade
  fill(108, 55, 55);
  triangle(180, 160, 200, 90, 200, 160);
  triangle(220, 160, 220, 60, 230, 160);

  //painting
  strokeWeight(10);
  stroke(67, 52, 35);
  rectMode(CENTER);
  rect(400, 0, 140, 160);

  //remove changes to rectMode,stroke and stroke weight
  noStroke();
  rectMode(CORNERS);
  strokeWeight(1);

  //dog body
  fill(184, 143, 89);
  rect(80, 180, 180, 300);
  triangle(80, 180, 80, 300, 20, 240);

  //back legs
  fill(203, 164, 111);
  ellipse(80, 240, 90, 90);
  rect(60, 280, 120, 300);

  //back toes
  fill(255);
  triangle(120, 280, 140, 300, 110, 300);
  stroke(216);
  line(120, 280, 130, 299);
  noStroke(); 

  //front legs
  fill(203, 164, 111);
  ellipse(160, 220, 70, 80);
  rect(140, 240, 180, 300);
  triangle(330, 200, 360, 280, 330, 280);

  //head
  noStroke();
  fill(184, 143, 89);
  rect(180, 160, 330, 300, 15);

  //front toes left side
  fill(255);
  quad(140, 280, 130, 300, 190, 300, 180, 280);
  stroke(216);
  line(140, 280, 130, 299);
  line(140, 280, 140, 299);
  line(160, 280, 160, 299);
  line(180, 280, 180, 299);
  noStroke();

  //front toes right side
  quad(330, 280, 330, 300, 390, 300, 380, 280);
  stroke(216);
  line(340, 279, 340, 299);
  line(360, 279, 360, 299);
  line(380, 279, 380, 299);
  noStroke();

  //eyes
  fill(255);
  ellipse(220, 220, 45, 45);
  ellipse(300, 220, 45, 45);

  //irises
  fill(103, 71, 37);
  ellipse(210+mouseX*0.05, 210+mouseY*0.05, 20, 20);
  ellipse(290+mouseX*0.05, 210+mouseY*0.05, 20, 20);
  fill(0);
  ellipse(210+mouseX*0.05, 210+mouseY*0.05, 10, 10);
  ellipse(290+mouseX*0.05, 210+mouseY*0.05, 10, 10);

  //eyeshine
  fill(255);
  ellipse(205+mouseX*0.05, 205+mouseY*0.05, 5, 5);
  ellipse(285+mouseX*0.05, 205+mouseY*0.05, 5, 5);

  //eyebrows/eyelids
  fill(184, 143, 89);
  rectMode(CORNER);
  rect(190, 187+mouseY*0.025, 55, 20);
  rect(270, 187+mouseY*0.025, 55, 20);
  rectMode(CORNERS);

  //eyebrows emphasis
  strokeWeight(3);
  stroke(85, 47, 21);
  line(200, 206+mouseY*0.025, 240, 206+mouseY*0.025);
  line(280, 206+mouseY*0.025, 320, 206+mouseY*0.025);
  noStroke();

  //mouth
  fill(23, 20, 17);
  quad(250, 240, 280, 240, 340, 300, 200, 300);
  rect(195, 280, 345, 300, 15);
  fill(8);
  quad(250, 240, 280, 240, 270, 250, 260, 250);
  strokeWeight(2);
  stroke(8);
  line(265, 250, 265, 298);
  noStroke();

  //ears
  fill(52, 36, 19);
  quad(180, 140, 200, 140, 220, 160, 180, 190);
  triangle(300, 160, 330, 200, 330, 150);
  fill(28, 20, 11);
  quad(160, 140, 200, 140, 170, 200, 160, 200);
  quad(330, 150, 350, 180, 350, 200, 330, 180);

  //white pattern
  fill(255);
  triangle(260, 180, 280, 240, 250, 240);

  //dog bed arm
  fill(234, 199, 199);
  ellipse(0, 270, 140, 140);
  fill(211, 179, 179);
  ellipse(0, 270, 100, 100);
}

void mousePressed() {
  frameRate(5);
  fill(234, 173, 200);
  quad(250, 280, 280, 280, 290, 300, 240, 300);
  fill(255);
  triangle(250, 280, 260, 280, 255, 290);
  triangle(260, 280, 270, 280, 265, 290);
  triangle(270, 280, 280, 280, 275, 290);
  println("Borf.");
}