Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
// Spring Butterfly

/* When the user moves the butterfly around, 
the human eyes follows it around. */

/* The butterfly supposed to be active and high flying during daytime. But
at night, the butterfly lands on the ground or on a flower and ends his day
of flying about. */

void setup() {
  // Set the size of the window
  size(400, 400);
  frameRate(60);
}

void draw() {
  // framerate
  frameRate(60);
  
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
    
  // SCENERY
    
  // sky background
  background(39, 159, 255);
  
  // Night Layer
  fill(0, 10, 67, -75 + mouseY);
  rect(200, 200, 400, 400);
  
  // sun
  noStroke();
  fill(255, 226, 0);
  ellipse(40, 40, 200, 200);
  fill(250, 255, 0);
  ellipse(40, 40, 180, 180);
  
  // moon layer
  noStroke();
  fill(237, -75 + mouseY);
  ellipse(40, 40, 200, 200);
  fill(255, -75 + mouseY);
  ellipse(40, 40, 180, 180);
  
  // clouds
  noStroke();
  fill(255, 200);
  ellipse(0 + mouseX, 60, 150, 20);
  ellipse(77 + mouseX, 44, 150, 20);
  ellipse(-103 + mouseX, 50, 150, 20);
  
  //Draw grassy hill
  noStroke();
  fill(24, 134, 6);
  ellipse(200, 400, 550, 150);
  fill(22, 90, 10);
  ellipse(200, 300, 550, 150);
  
  //Flower stem and petals (foreground)
  noFill();
  stroke(6,255,0);
  strokeWeight(6);
  bezier(100, 400, 90, 360, 80, 320, 60, 280);
  noStroke();
  fill(232, 89, 173);
  ellipse(40, 260, 35, 35);
  ellipse(70, 260, 35, 35);
  ellipse(40, 290, 35, 35);
  fill(246, 255, 0);
  ellipse(55, 275, 30, 30);
  
  //Dandelion (background)
  noFill();
  stroke(57, 116, 55);
  strokeWeight(2);
  bezier(280, 372, 282, 362, 285, 342, 290, 332);
  noStroke();
  fill(193);
  ellipse(290, 330, 12, 12);
    
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  // HUMAN FIGURE
  
  // set CENTER mode
  ellipseMode(CENTER);
  rectMode(CENTER);
  
  strokeWeight(1);
  
  // human head
  noStroke();
  fill(255, 193, 116);
  ellipse(200, 140, 80, 80);
  fill(255, 216, 167);
  ellipse(197.5, 137.5, 73, 73);
  
  // human eyes
  noStroke();
  fill(33, 19, 4);
  ellipse(175 + (mouseX * .05), 125 + (mouseY * .07), 10, 10);
  ellipse(205 + (mouseX * .05), 125 + (mouseY * .07), 10, 10);
  
  // nose
  stroke(0);
  fill(250, 168, 91);
  ellipse(190 + (mouseX * .05), 135 + (mouseY * .07), 10, 5);
  
  // human body
  noStroke();
  fill(255, 128, 0);
  rect(200, 245, 60, 130);
  noStroke();
  // brighter part
  fill(255, 170, 0);
  rect(198, 242.5, 55, 125);
  
  // human arms + hands (R + L)
  noStroke();
  fill(255, 128, 0);
  rect(160, 240, 20, 120);
  rect(240, 240, 20, 120);
  fill(255, 193, 116);
  ellipse(160, 310, 20, 20);
  ellipse(240, 310, 20, 20);
  // brighter area
  fill(255, 170, 0);
  rect(157.5, 237.5, 15, 115);
  rect(237.5, 237.5, 15, 115);
  fill(255, 216, 167);
  ellipse(159, 309, 17, 17);
  ellipse(239, 309, 17, 17);
    
  // human legs
  noStroke();
  fill(0, 25, 144);
  rect(200, 355, 60, 90);
  fill(0, 18, 93);
  rect(200.5, 365, 16, 70);
  stroke(0);
  strokeWeight(1); // GOTTA MAKE IT FOR JUST THE ONE LINE!!
  line(200, 400, 200, 330);
  line(210, 330, 190, 330);

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  // BUTTERFLY

  // Butterfly (mouse follow cursor)
  stroke(39);
  bezier(-10 + mouseX, -25 + mouseY, -8 + mouseX, -30 + mouseY, -3 + mouseX, -10 + mouseY, -1 + mouseX, -5 + mouseY);
  bezier(10 + mouseX, -25 + mouseY, 8 + mouseX, -30 + mouseY, 3 + mouseX, -10 + mouseY, 1 + mouseX, -5 + mouseY);
  fill(39);
  ellipse(-10 + mouseX, -25 + mouseY, 5, 5);
  ellipse(10 + mouseX, -25 + mouseY, 5, 5);
  stroke(255);
  fill(255, 115, 0);
  ellipse(-10 + mouseX, -7 + mouseY, 14, 15);
  ellipse(-10 + mouseX, 7 + mouseY, 14, 15);
  ellipse(10 + mouseX, -7 + mouseY, 14, 15);
  ellipse(10 + mouseX, 7 + mouseY, 14, 15);
  fill(39);
  noStroke();
  ellipse (mouseX, mouseY, 14, 19);
}

// PRESS THE LEFT MOUSE BUTTON FOR "OOOH, A BUTTERFLY."

void mousePressed() {
  
  println("Oooh, a butterfly!");
}