Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next

//world setup starts here
void setup() {
size(400,400);//set canvas size to 400x400
frameRate(5);
background(240,240,240);//set background colour
}



//Draw loop starts here
void draw(){
  
  //COVERING THE BACKGROUND FOR THE FLAPPING ANIMATION//
  fill(240,240,240);
  noStroke();
  ellipse(275,245,200,200);
  
  
  ////////////////////////CHICKEN/////////////////////////////////
  //COLOUR TORSO AND TAIL WITH LINES (solely for filling blank space with colour)//
  stroke(255);
  strokeWeight(10);
  line(180,190, 245,185);
  line(245,175, 245,187);
  line(245,175, 238,187);
  strokeWeight(3);
  line(257,182, 245,179);
  line(254,172, 245,171);
  stroke(0);
  strokeWeight(1.5);
  
  //HEAD FEATHERS//
  fill(255,150,150);//set fill to a dull red
  arc(width/2-17, height/2-50, 15, 15, PI, PI*2);//leftmost feather arc
  arc(width/2-5, height/2-50, 10,10, PI-QUARTER_PI/4, PI*2+QUARTER_PI/2);//middle feather arc
  arc(width/2+2, height/2-42, 14, 13, PI+PI/3, PI*2+QUARTER_PI);//rightmost feather arc
  //The lines below are for filling with colour
  strokeWeight(8);
  stroke(255,150,150);
  line(180,152,197,155);
  line(200,157,197,155);
  stroke(0);
  strokeWeight(1.5);
  line(176,156,175,150);//this line connects the leftmost arc to the head of the chicken
  
  //BODY//
  fill(255);
  arc(width/2-6, height/2+11, 90, 90, -QUARTER_PI/2, PI+QUARTER_PI/4);//the first layer of the chicken's body arc 
  arc(width/2+3, height/2+5, 105, 100, -QUARTER_PI/2, PI+QUARTER_PI/4); //this body arc goes over the first body arc to hide the stroke
  noStroke();//remove stroke for a colouring arc
  arc(width/2-1, height/2+5, 99, 101, -QUARTER_PI/2, PI+QUARTER_PI/4);//this arc is for colouring over stroke
  stroke(0);//reenable stroke
  arc(width/2-15, height/2-10, 66, 65, PI, PI*2-QUARTER_PI/3.3);//the arc at the head of the chicken
  line(217,183,235,180);//line between head arc and tail
  

  
  //TAIL//
  noFill();//disable fill
  arc(width/2+48, height/2-20, 25, 20, PI, PI+QUARTER_PI/2*7);//topmost tail feather arc  
  arc(width/2+55, height/2-22, 10, 8, PI, PI+QUARTER_PI/2*7);//second tail feather arc
  arc(width/2+51, height/2-8, 28, 15, PI+HALF_PI, PI+QUARTER_PI*3);//bottommost tail feather arc
  fill(255);//apply fill because it's safe to do so with the following arc
  arc(width/2+51, height/2-14, 18, 15, PI+HALF_PI, PI*2);//third tail feather arc     
  
  //WING//
  arc(width/2+10, height/2, 60, 50, -QUARTER_PI/2, HALF_PI+HALF_PI/2);//the arc of the wing
  line(215,195,236,189);//the line for the wing
  
  //BEAK FEATHERS//
  fill(255,150,150);//set the fill to a dull red
  noStroke();
  ellipse(173,205,20,11);//fill empty space with an ellipse meant for colouring
  stroke(0);//reapply stroke for the next arcs
  arc(width/2-33, height/2+8, 8, 12, QUARTER_PI/4, PI+QUARTER_PI);//leftmost feather arc
  arc(width/2-24, height/2+5, 13, 16, -HALF_PI/2, HALF_PI+HALF_PI/2);//rightmost feather arc
  
  //BEAK//
  fill(255,255,150);//change fill to a dull yellow
  ellipse(width/2-40,height/2-4,40,16);//ellipse for the beak
  
  //EYE//
  fill(0);//set fill to black
  ellipse((mouseX-width/2-15) * 0.005 + 185,(mouseY-height/2-17) * 0.005 + 183,6,6);//the eye ellipse 

  }
  
  //keyPressed function places an arc to represent the wing and covers the old wing
  void keyPressed(){
  fill(255);
  noStroke();
  arc(width/2+12, height/2+10, 55, 40, 0, PI*2);//this arc covers the old wing
  stroke(0);
  arc(width/2, height/2-10, 90, 65, -PI/3, HALF_PI);//the new wing that gets placed
  noStroke();
  arc(width/2+5, height/2+2, 34, 40, 0, PI*2);//this arc covers part of the stroke of the new wing
  }
  
  //mousepressed function that makes the chicken blink
  void mousePressed(){
    fill(255);
    noStroke();
    ellipse((mouseX-width/2-15) * 0.01 + 185,(mouseY-height/2-17) * 0.01 + 183,12,12);//place a white ellipse over the eye
  }