Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/* Faun on Panflute
By: Porter Crease

A musical faun with an idle tapping hoof is chilling out in the forest.

The forest critters will scurry from the left to the right of the screen according to the position of the mouse. 
Click to watch the faun play on his panflute!

*/

void setup() {
  size(400, 400);
}




void draw() {
  //return the framerate to normal after a mouse click
    frameRate(60);
  background(67, 74, 81);

  noStroke();



  //  pink, faraway light
  fill(250, 175, 212);
  ellipse(width/2, 100, 500, 300);

  //farthest trees
  fill(120, 114, 134);
  rect(50, 0, 40, height);
  rect(230, 0, 40, height);
  rect(350, 0, 40, height);

  //ground
  fill(125, 189, 189);
  rect(0, 280, width, 120);
  fill(174, 215, 190);
  ellipse(220, 350, 280, 80);


  //background trees
  fill(83, 72, 91);
  rect(20, 0, 40, 305);
  rect (120, 0, 50, 305);
  rect (280, 0, 50, 285);
  fill(59, 60, 73);
  rect (370, 0, 50, 295);
  rect (200, 0, 50, 295);


  //bunny, moves with x cordinates of mouse, fastest animal to move from left to right.
  fill(255);
  //body
  arc((mouseX-120)*3, 310, 50, 50, PI, TWO_PI);
  //legs
  ellipse((mouseX-113)*3, 311, 10, 20);
  ellipse((mouseX-127)*3, 312, 10, 20);
  //tail
  ellipse((mouseX-129)*3, 300, 10, 10);
  //head
  ellipse((mouseX-110)*3, 300, 25, 15);
  //ear
  ellipse((mouseX-112)*3, 285, 10, 20);


  //rock
  fill(111, 105, 127);
  arc(130, 330, 180, 180, PI, TWO_PI);

  //right leg
  fill(200, 122, 100);
  ellipse(130, 220, 90, 50);
  quad(160, 230, 145, 260, 160, 260, 175, 220);
  //ankle area of leg moves in an arc
  quad(160, 248, 160, 260, 205+abs(3*sin(frameCount*0.1)), 260+10*cos(frameCount*0.1), 210+abs(3*sin(frameCount*0.1)), 250+10*cos(frameCount*0.1));
  //hoof
  fill(218, 205, 205);
  arc(205+abs(3*sin(frameCount*0.1)), 270+10*cos(frameCount*0.1), 28, 44, PI+0.2, TWO_PI+0.2);

  //right arm
  //shoulder
  fill(152, 130, 186);
  ellipse(147, 143, 30, 30);
  //arm
  rect(137, 143, 15, 50);
  rect(140, 200, 40, 20);


  //tail
  fill(153, 109, 97);
  ellipse(65, 220, 25, 25);
  stroke(153, 109, 97);
  strokeWeight(6);
  noFill();
  arc(60, 215, 20, 30, PI+HALF_PI+0.4, TWO_PI+HALF_PI-0.4);

  noStroke();

  //tummy
  fill(188, 167, 212);
  ellipse(105, 225, 70, 50);

  //back
  arc(130, 230, 119, 200, PI, PI+HALF_PI);

  //chest
  ellipse(125, 160, 40, 60);

  //left leg
  fill(200, 122, 100);
  ellipse(90, 250, 50, 80);
  rect(90, 279, 19, 10);
  //ankle
  quad(80, 310, 90, 320, 120, 280, 110, 280);
  //hoof
  fill(200, 200, 200);
  arc(89, 325, 36, 38, PI-0.8, TWO_PI-0.8);

  //panflute
  fill(255, 232, 200);
  quad(123, 186, 135, 186, 135, 230, 123, 230);
  fill(206, 183, 151);
  quad(135, 186, 145, 186, 145, 230, 135, 230);
  fill(230, 221, 177);
  quad(145, 186, 155, 186, 155, 230, 145, 230);
  //other visible pipes are shorter
  fill(217, 200, 154);
  quad(155, 186, 165, 186, 165, 220, 155, 220);
  fill(233, 221, 190);
  quad(165, 186, 175, 186, 175, 210, 165, 210);

  //righthand
  fill(159, 143, 184);
  ellipse(183, 210, 30, 35);

  //armleft
  fill(217, 200, 225);
  //bicep
  quad(80, 170, 95, 170, 95, 212, 80, 212);
  //forearm
  quad(80, 212, 130, 212, 130, 235, 80, 235);
  //shoulder
  fill(233, 208, 238);
  ellipse(90, 170, 30, 30);
  //hand
  ellipse(135, 220, 30, 35);

  //horns
  stroke(255);
  strokeWeight(13);
  line(75, 80, 152, 80);
  strokeWeight(10);
  noFill();
  arc(152, 67, 20, 30, PI+HALF_PI+0.4, TWO_PI+HALF_PI-0.4);
  arc(78, 67, 20, 30, HALF_PI+0.4, PI+HALF_PI-0.4);
  noStroke();

  fill(217, 200, 225);
  //ears
  arc(160, 100, 40, 20, 0, PI);
  arc(160-85, 100, 40, 20, 0, PI);


  //head
  ellipse(115, 100, 63, 60);
  //chin
  arc(135-20, 143, 28, 100, PI+0.5, TWO_PI);
  //left cheek
  arc(126-12, 129-19, 45, 65, 0, PI+0.9);
  //right cheek
  arc(126-3, 129-19, 45, 65, PI, TWO_PI+HALF_PI);

  //hair
  fill(153, 109, 97);
  ellipse(118, 70, 25, 25);
  stroke(153, 109, 97);
  strokeWeight(10);
  noFill();
  arc(120, 67, 20, 30, PI+HALF_PI+0.4, TWO_PI+HALF_PI-0.4);

  //eyes
  strokeCap(ROUND);
  strokeWeight(3);
  stroke(141, 154, 197);
  line(113, 94, 113, 104);
  line(130, 94, 130, 104);
  noStroke();

  //mouse scurries left to right, starts off in the middle of the screen but moves slowest
  //body
  noFill();
  stroke(161, 143, 169);
  strokeWeight(15);
  arc((mouseX+30)*1.5, 375, 30, 10, PI, TWO_PI);
  //tail
  strokeWeight(3);
  arc((mouseX+05)*1.5, 375, 30, 10, 0, PI);
  //mouse head
  noStroke();
  fill(161, 143, 169);
  triangle((mouseX+43)*1.5, 383, (mouseX+43)*1.5, 358, (mouseX+55)*1.5, 374);
  //ear
  ellipse((mouseX+43)*1.5, 361, 15, 20);
  noStroke();


  //squirrel scurries left to right
  noFill();
  stroke(150, 120, 100);
  strokeWeight(15);
  arc((mouseX-100)*2, 340, 40, 20, PI, TWO_PI);
//legs
  strokeWeight(4);
  line((mouseX-112)*2, 346, (mouseX-114)*2, 352);
  line((mouseX-108)*2, 345, (mouseX-110)*2, 351);
  line((mouseX-89)*2, 342, (mouseX-86)*2, 352);
  line((mouseX-87)*2, 338, (mouseX-84)*2, 344);
  noStroke();
  //head
  fill(150, 120, 100);
  ellipse((mouseX-85)*2, 328, 25, 25);
  //tail
  arc((mouseX-111)*2, 326, 20, 30, HALF_PI, PI+HALF_PI);
  //ears
  ellipse((mouseX-89)*2, 314, 7, 10);
  ellipse((mouseX-84)*2, 314, 7, 10);

  //foreground tree
  fill(21, 20, 23);
  rect(0, 0, 40, height);
  quad(40, 75, 40, 40, 100, 0, 110, 0);
}
  
  
  
  
  

void mousePressed() {
  frameRate(1);
  //redraw the scene




  //  faraway light
  fill(250, 175, 212);
  ellipse(width/2, 100, 500, 300);

  //super back trees
  fill(120, 114, 134);
  rect(50, 0, 40, height);
  rect(230, 0, 40, height);
  rect(350, 0, 40, height);

  //ground
  fill(125, 189, 189);
  rect(0, 280, width, 120);
  fill(174, 215, 190);
  ellipse(220, 350, 280, 80);


  //back trees
  fill(83, 72, 91);
  rect(20, 0, 40, 305);
  rect (120, 0, 50, 305);
  rect (280, 0, 50, 285);
  fill(59, 60, 73);
  rect (370, 0, 50, 295);
  rect (200, 0, 50, 295);


  //bunny
  fill(255);
  //body
  arc((mouseX-120)*3, 310, 50, 50, PI, TWO_PI);
  //legs
  ellipse((mouseX-113)*3, 311, 10, 20);
  ellipse((mouseX-127)*3, 312, 10, 20);
  //tail
  ellipse((mouseX-129)*3, 300, 10, 10);
  //head
  ellipse((mouseX-110)*3, 300, 25, 15);
  //ear
  ellipse((mouseX-112)*3, 285, 10, 20);


  //rock
  fill(111, 105, 127);
  arc(130, 330, 180, 180, PI, TWO_PI);

  //leggy right
  fill(200, 122, 100);
  ellipse(130, 220, 90, 50);
  //joint1
  quad(160, 230, 145, 260, 160, 260, 175, 220);
  //ankley part-- moves in an arc
  quad(160, 248, 160, 260, 205+abs(5*sin(frameCount*0.1)), 260+10*cos(frameCount*0.1), 210+abs(5*sin(frameCount*0.1)), 250+10*cos(frameCount*0.1));
  //hoof
  fill(218, 205, 205);
  arc(205+abs(5*sin(frameCount*0.1)), 270+10*cos(frameCount*0.1), 28, 44, PI+0.2, TWO_PI+0.2);

  //armright
  //shoulder
  fill(152, 130, 186);
  ellipse(147, 143, 30, 30);
  //arm
  quad(143, 153, 159, 139,191,155,195,176);
  quad(185, 124, 212, 124,195,176,185,154);

  //righthand
  fill(159, 143, 184);
  ellipse(200, 118, 30, 35);


  //tail
  fill(153, 109, 97);
  ellipse(65, 220, 25, 25);
  stroke(153, 109, 97);
  strokeWeight(6);
  noFill();
  arc(60, 215, 20, 30, PI+HALF_PI+0.4, TWO_PI+HALF_PI-0.4);

  noStroke();

  //tummy
  fill(188, 167, 212);
  ellipse(105, 225, 70, 50);

  //back
  arc(130, 230, 119, 200, PI, PI+HALF_PI);

  //chest
  ellipse(125, 160, 40, 60);

  //leggyleft
  fill(200, 122, 100);
  ellipse(90, 250, 50, 80);
  //joint
  // rect();
  rect(90, 279, 19, 10);
  //ankley bit
  quad(80, 310, 90, 320, 120, 280, 110, 280);
  //hoof
  fill(200, 200, 200);
  arc(89, 325, 36, 38, PI-0.8, TWO_PI-0.8);

//hair behind head
  fill(123, 89, 77);
  ellipse(98, 79, 25, 25);
  stroke(123, 89, 77);
  strokeWeight(10);
  noFill();
  arc(98, 79, 20, 30, PI+HALF_PI+0.4, TWO_PI+HALF_PI-0.4);
  noStroke();

  //horn to the right
  stroke(255);
  strokeWeight(13);
  line(90, 113, 150, 78);
  strokeWeight(10);
  noFill();
  arc(150, 65, 10, 30, PI+HALF_PI+0.4, TWO_PI+HALF_PI-0.4);
  noStroke();

  fill(217, 200, 225);
  //ears ++ TILTED
  arc(155, 90, 40, 20, 0-1, PI-1);
  arc(80, 120, 40, 20, 0-1, PI-1);


  //face
  fill(217, 200, 225);
  //head
  ellipse(120, 105, 63, 60);
  //cheeks
  arc(135, 143, 28, 100, PI+0.5, TWO_PI);
  arc(126, 129, 45, 30, 0, PI+0.3);

  //horn overlapping head
  stroke(255);
  line(90, 113, 100, 100);
  arc(90, 100, 10, 30, HALF_PI+0.4, PI+HALF_PI-0.4);

  //eyes
  noFill();
  strokeWeight(2);
  stroke(0, 0, 0);
  arc(117, 120, 20, 10, 0, HALF_PI);
  arc(140, 112, 20, 10, 0, HALF_PI);
  noStroke();
  //hair ++ side of mohawk showing
  fill(143, 99, 87);
  ellipse(116, 75, 25, 25);
  fill(153, 109, 97);
  ellipse(128, 89, 25, 25);
  stroke(153, 109, 97);
  strokeWeight(10);
  noFill();
  arc(128, 87, 20, 30, PI+HALF_PI+0.4, TWO_PI+HALF_PI-0.4);
  noStroke();

  //panflute (90x63 pixels) smallest (90x23)// each individual pipe is 10p wide
  
  //coordinates = (top left, top right, bottom right, bottom left)
  fill(255, 232, 200);
  quad(138, 138, 146, 130, 162, 155, 154, 164);
  fill(206, 183, 151);
  quad(146, 130, 154, 122, 178, 154, 167, 163);
  fill(230, 221, 177);
  quad(154, 122, 163, 114, 192, 152, 184, 163);
  fill(217, 200, 154);
quad(163, 114, 172, 106, 195, 136, 186, 145);
  fill(233, 221, 190);
quad(172, 106, 180, 98, 194, 121, 186, 127);
  
    //armleft
  fill(217, 200, 225);
  //bicep (15 wide, 42 high)
  quad(86, 181, 92, 166, 121, 197, 110, 207);
  //forearm
  quad(110, 207, 128, 225, 144, 180, 132, 165);
  //shoulder
  fill(233, 208, 238);
  ellipse(90, 170, 30, 30);
  //hand
 ellipse(142, 170, 30, 35);


  //shadows
  fill(0, 0, 20, 75);
  triangle(0, 58, 81, 350, 0, 350);
  quad(362, 350, 100, 0, 400, 0, 400, 350);
  rect(0, 350, width, 50);
  //spotlight
  fill(174, 215, 190);
  arc(220, 350, 280, 80, 0, PI);
  
  //mouse
  //body
  noFill();
  stroke(161, 143, 169);
  strokeWeight(15);
  arc((mouseX+30)*1.5, 375, 30, 10, PI, TWO_PI);
  //tail
  strokeWeight(3);
  arc((mouseX+05)*1.5, 375, 30, 10, 0, PI);
  //mouse head
  noStroke();
  fill(161, 143, 169);
  triangle((mouseX+43)*1.5, 383, (mouseX+43)*1.5, 358, (mouseX+55)*1.5, 374);
  //ear
  ellipse((mouseX+43)*1.5, 361, 15, 20);
  noStroke();


  //squirrel
  noFill();
  stroke(150, 120, 100);
  strokeWeight(15);
  arc((mouseX-100)*2, 340, 40, 20, PI, TWO_PI);

  strokeWeight(4);
  line((mouseX-112)*2, 346, (mouseX-114)*2, 352);
  line((mouseX-108)*2, 345, (mouseX-110)*2, 351);
  line((mouseX-89)*2, 342, (mouseX-86)*2, 352);
  line((mouseX-87)*2, 338, (mouseX-84)*2, 344);
  noStroke();
  //head
  fill(150, 120, 100);
  ellipse((mouseX-85)*2, 328, 25, 25);
  //tail
  arc((mouseX-111)*2, 326, 20, 30, HALF_PI, PI+HALF_PI);
  //ears
  ellipse((mouseX-89)*2, 314, 7, 10);
  ellipse((mouseX-84)*2, 314, 7, 10);
  
    //foreground trees
  fill(21, 20, 23);
  rect(0, 0, 40, height);
  quad(40, 75, 40, 40, 100, 0, 110, 0);

}