Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/*
Title: Beautiful Morning
By: Raj Vijayakumar (Student#: 991 487 624)
Date: Sept 20, 2018

Intro to Media Computation
Instructor: Nicolas Hesler

Description:
-Move the mouse up and down to move the toaster lever and toast.
-Click mouse to fill glass with orange juice. 
-Press any key to reveal hidden message.
*/

void setup(){
  //Setup canvas
  size(400,400);
  //Cursor not visible in the program
  noCursor();
}

void draw(){
  //Default framerate
  frameRate(60);
  
  //Set background wall color
  background(255,229,157);
  
  //Draw countertop
  noStroke();
  fill(137,102,50);
  rect(0,300,400,20);
  fill(219,160,71);
  rect(0,220,400,80);
  
  //Draw toaster
  fill(97,98,98);
  rect(100,120,160,120,30,30,5,5);
  fill(235,239,240);
  rect(110,240,30,10,0,0,30,30);
  rect(220,240,30,10,0,0,30,30);
  rect(120,120,120,110,30,30,0,0);
  fill(0);
  rect(130,120,100,10,0,0,100,100);
  ellipseMode(CENTER);
  fill(93,57,22);
  
  //Draw window
  fill(227,114,39);
  rect(0,0,90,140);
  fill(164,222,242);
  rect(0,0,80,130);
  fill(252,245,224);
  rect(0,0,10,130);
  rect(0,60,80,10);
  
  //draw toaster lever
  fill(120,126,126);
  rect(260,mouseY-height+550,20,10);
  
  //draw toast
  fill(206,174,83);
  rect(140,(mouseY+60),80,60);
  fill(245,219,146);
  rect(145,mouseY+65,70,50);
  
  //draw glass cup
  fill(202,247,247,150);
  quad(320,160,370,160,360,240,330,240);
  
  //draw bowl
  fill(255,244,219);
  ellipse(275,220,90,20);
  quad(230,220,320,220,300,270,250,270);
  fill(250,207,88);
  ellipse(275,220,80,10);
  
  //Draw a layer over the path of toast and lever to keep it hidden
  fill(235,239,240);
  rect(140,130,80,100);
  fill(219,160,71);
  rect(260,270,20,30);
  rect(140,240,80,60);
  ellipse(210,210,20,20);//Toaster Knob
  fill(97,98,98);
  rect(140,230,80,10);
  fill(137,102,50);
  rect(140,300,80,20);
  rect(260,300,20,20);
  
  //Draw steam coming from the bowl
  fill(255,255,255,130);
  ellipse(290, 190, 30 + ((float) Math.sin(frameCount * 0.05) * 8), 30 + ((float) Math.sin(frameCount * 0.05) * 8));
  ellipse(270, 200, 30 + ((float) Math.sin(frameCount * 0.05) * 8), 30 + ((float) Math.sin(frameCount * 0.05) * 8));

  //Draw cabinets and drawers
  fill(216,127,17);
  rect(0,320,400,80);
  strokeWeight(3);
  stroke(0);
  line(80,321,80,400);
  line(280,321,280,400);
  line(80,360,280,360);
  noStroke();
  fill(237,178,105);
  rect(85,325,190,30);
  rect(85,365,190,30);
  rect(0,325,75,75);
  rect(285,325,115,75);
  stroke(255);
  strokeWeight(5);
  line(110,340,250,340);
  line(110,380,250,380);
  line(60,360,60,400);
  line(300,360,300,400);
}

//Mouse click fills glass with orange juice
void mousePressed(){
  //Framerate when mouse is clicked
  frameRate(0.75);
  noStroke();
  fill(245,220,30);
  quad(325,170,365,170,355,230,335,230);
  
}

//Key press makes the hidden message appear
void keyPressed(){
  //Framerate when is gets pressed
  frameRate(0.75);
  noStroke();
  
  //Hidden message background
  fill(198,50,50,200);
  rect(235,17.5,90,25);
  rect(255,47.5,140,25);
  
  //G
  strokeWeight(3);
  stroke(0);
  line(260,20,240,20);
  line(240,20,240,40);
  line(260,40,240,40);
  line(260,30,260,45);
  
  //O
  noFill();
  rect(265,20,15,20);
  
  //O
  rect(285,20,15,20);
  
  //D
  rect(305,20,15,20,0,5,5,0);
  
  //M
  line(260,50,260,70);
  line(260,50,270,60);
  line(270,60,280,50);
  line(280,50,280,70);
  
  //O
  rect(285,50,15,20);
  
  //R
  rect(305,50,15,10);
  line(305,60,305,70);
  line(310,60,320,70);
  
  //N
  line(325,70,325,50);
  line(325,50,340,70);
  line(340,70,340,50);
  
  //I
  line(345,50,345,70);
  
  //N
  line(350,70,350,50);
  line(350,50,365,70);
  line(365,70,365,50);
  
  //G
  line(390,50,370,50);
  line(370,50,370,70);
  line(370,70,390,70);
  line(390,60,390,75);
}