Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/* Tim Lee
 "froge" will follow the buzzing fly on your cursor.
 The sky's colour and the clouds' position will change along with the cursor.
 On clicking, "froge" will become enraged and attempt to eat your cursor, and telepathically display the word "Ribbit" on the Console.
 Have fun! */

void setup() {
  size (400, 400);
}
//start loop and rectmode
void draw() {
  //set framerate
  frameRate(60);
  rectMode(CENTER);

  //sky
  background(250-((mouseX+mouseY)/25), 187+((mouseX+mouseY)/12), 0+((mouseX+mouseY)/3));

  //back cloud
  stroke(230, 230, 230);
  fill(255, 255, 255, 144);
  ellipse(75+(mouseX+mouseY)/8, 75, 250, 75);

  //sun
  noStroke();
  fill(255, 127, 0);
  ellipse(0, 0, 350-((mouseX+mouseY)/4), 350-((mouseX+mouseY)/4));
  fill(255, 255, 0);
  ellipse(0, 0, 280-((mouseX+mouseY)/4), 280-((mouseX+mouseY)/4));

  //water
  strokeWeight(2);
  stroke(0, 165, 221);
  fill(4, 200, 249);
  rect(200, 300, 402, 200);
  noStroke();
  fill(0, 185, 232);
  rect(200, 350, 402, 200);
  fill(0, 172, 216);
  rect(200, 400, 402, 200);
  fill(0, 168, 211);
  rect(200, 450, 402, 200);

  //lilypad
  stroke(15, 137, 0);
  fill(20, 175, 0);
  ellipse(200, 300, 250, 125);
  //place lilypad water triangle
  noStroke();
  fill(0, 172, 216);
  triangle(243, 362, 225, 315, 288, 347);
  //lilypad cutout outline
  stroke(15, 137, 0);
  line(243, 358, 225, 315);
  line(225, 315, 284, 345);

  //front cloud
  stroke(230, 230, 230);
  fill(255, 255, 255, 144);
  ellipse(100+(mouseX+mouseY)/3, 100, 250, 75);

  //place down back left and right legs
  stroke(38, 153, 0);
  fill(48, 196, 0);
  quad(110, 295, 95, 235, 140, 265, 145, 285);
  quad(260, 295, 275, 235, 230, 265, 225, 285); 

  //body (head more like)
  ellipse(185, 240, 140, 90);

  //place left and right eyeballs
  stroke(0);
  fill(255);
  ellipse(140, 205, 30, 30);
  ellipse(230, 205, 30, 30);

  //place left and right pupils
  fill(0);
  ellipse(140+(mouseX-200)/20, 207+(mouseY-200)/60, 5, 5);
  ellipse(230+(mouseX-200)/20, 207+(mouseY-200)/60, 5, 5);

  //place left and right eyelids
  stroke(38, 153, 0);
  fill(48, 196, 0);
  arc(140, 205, 30, 30, -PI, 0);
  arc(230, 205, 30, 30, -PI, 0);

  //place down front legs and feet
  ellipse(155, 290, 30, 35);
  ellipse(215, 290, 30, 35);
  ellipse(110, 290, 30, 25);
  ellipse(260, 290, 30, 25);

  //place down toes
  //back left
  ellipse(95, 300, 10, 10);
  ellipse(110, 305, 10, 10);
  ellipse(125, 300, 10, 10);
  //front left
  ellipse(140, 305, 10, 10);
  ellipse(155, 310, 10, 10);
  ellipse(170, 305, 10, 10);
  //front right
  ellipse(200, 305, 10, 10);
  ellipse(215, 310, 10, 10);
  ellipse(230, 305, 10, 10);
  //back right
  ellipse(245, 300, 10, 10);
  ellipse(260, 305, 10, 10);
  ellipse(275, 300, 10, 10);

  //nostrils
  stroke(1);
  fill(1);
  ellipse(170, 225, 2, 2);
  ellipse(200, 225, 2, 2);

  //mouth
  noFill();
  stroke(38, 153, 0);
  curve(150, 350, 120, 250, 250, 250, 200, 350);


  //fly on cursor  
  stroke(0);
  fill(0);
  ellipse(mouseX+sin(frameCount)*5, mouseY+sin(frameCount)*9, 4, 4);
}

//tongue and eyes changing on click
void mousePressed() {
  //red eyes
  //place left and right eyeballs
  stroke(0);
  strokeWeight(2);
  fill(255);
  ellipse(140, 205, 30, 30);
  ellipse(230, 205, 30, 30);

  //place left and right pupils
  noStroke();
  fill(255, 0, 0);
  ellipse(140+(mouseX-200)/20, 207+(mouseY-200)/60, 10, 10);
  ellipse(230+(mouseX-200)/20, 207+(mouseY-200)/60, 10, 10);

  //tongue flying out on click
  rectMode(CORNER);
  frameRate(1); //framerate slows down to make the instant more visible
  strokeWeight(5);
  stroke(253, 191, 255);
  line(185, 238, mouseX, mouseY);

  //little message
  println("Ribbit.");
}