Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/*
 *  PROG14998: INTRODUCTION TO MEDIA COMPUTING
 *  FALL 2018, PROF: NICOLAS HESLER
 *
 *  BY TING PEI CHEN (ZOE)
 *
 *  ABOUT:
 *    An emoticon of great potential and caliber,
 *    inhibiting our still inability to escape the
 *    circumstance of a 400px by 400px canvas, and
 *    perhaps never will be any bigger than this.
 *
*/


void setup()  {
  
  /* SETUP */
  
  //canvas is 400px*400px
  size(400, 400);
  
  //no cursor
  noCursor();
}

void keyPressed()  {
  
  //open mouth
  frameRate(3);
  stroke(255-(mouseY/1.57), 0, 0);
  fill(255-(mouseY/1.57), 0, 0);
  arc(200+(mouseX/40), 200+(mouseY/40), 140, 140, QUARTER_PI, HALF_PI+QUARTER_PI);
  noStroke();
  
}

void mousePressed()  {
  
  //set low framerate
  frameRate(5);
  
  //alpha shifts low and high
  stroke(255, 225, 100, millis() % 120);
  
  //lightning
  strokeWeight(4);
  
  //left
  line(60+((20/9)*mouseY), 60+(10*sin(0.7+frameCount*0.04)), 40+((20/9)*mouseY), 80+(10*sin(0.7+frameCount*0.04)));
  line(40+((20/9)*mouseY), 80+(10*sin(0.7+frameCount*0.04)), 60+((20/9)*mouseY), 100+(10*sin(0.7+frameCount*0.04)));
  line(60+((20/9)*mouseY), 100+(10*sin(0.7+frameCount*0.04)), 20+((20/9)*mouseY), 120+(10*sin(0.7+frameCount*0.04)));
  line(40+((20/9)*mouseY), 110+(10*sin(0.7+frameCount*0.04)), 60+((20/9)*mouseY), 120+(10*sin(0.7+frameCount*0.04)));
  line(60+((20/9)*mouseY), 120+(10*sin(0.7+frameCount*0.04)), 50+((20/9)*mouseY), 140+(10*sin(0.7+frameCount*0.04)));
  
  //center
  line(240+((20/9)*mouseY), 60+(10*sin(1+frameCount*0.04)), 220+((20/9)*mouseY), 80+(10*sin(1+frameCount*0.04)));
  line(220+((20/9)*mouseY), 80+(10*sin(1+frameCount*0.04)), 210+((20/9)*mouseY), 100+(10*sin(1+frameCount*0.04)));
  line(210+((20/9)*mouseY), 100+(10*sin(1+frameCount*0.04)), 230+((20/9)*mouseY), 120+(10*sin(1+frameCount*0.04)));
  line(230+((20/9)*mouseY), 120+(10*sin(1+frameCount*0.04)), 220+((20/9)*mouseY), 160+(10*sin(1+frameCount*0.04)));
  line(220+((20/9)*mouseY), 160+(10*sin(1+frameCount*0.04)), 260+((20/9)*mouseY), 220+(10*sin(1+frameCount*0.04)));
  line(260+((20/9)*mouseY), 220+(10*sin(1+frameCount*0.04)), 300+((20/9)*mouseY), 240+(10*sin(1+frameCount*0.04)));
  line(300+((20/9)*mouseY), 240+(10*sin(1+frameCount*0.04)), 310+((20/9)*mouseY), 260+(10*sin(1+frameCount*0.04)));
  
  line(260+((20/9)*mouseY), 220+(10*sin(1+frameCount*0.04)), 280+((20/9)*mouseY), 260+(10*sin(1+frameCount*0.04)));
  line(280+((20/9)*mouseY), 260+(10*sin(1+frameCount*0.04)), 270+((20/9)*mouseY), 280+(10*sin(1+frameCount*0.04)));
  
  line(210+((20/9)*mouseY), 100+(10*sin(1+frameCount*0.04)), 190+((20/9)*mouseY), 120+(10*sin(1+frameCount*0.04)));
  line(190+((20/9)*mouseY), 120+(10*sin(1+frameCount*0.04)), 180+((20/9)*mouseY), 140+(10*sin(1+frameCount*0.04)));
  line(180+((20/9)*mouseY), 140+(10*sin(1+frameCount*0.04)), 140+((20/9)*mouseY), 180+(10*sin(1+frameCount*0.04)));
  line(140+((20/9)*mouseY), 180+(10*sin(1+frameCount*0.04)), 120+((20/9)*mouseY), 240+(10*sin(1+frameCount*0.04)));
  line(120+((20/9)*mouseY), 240+(10*sin(1+frameCount*0.04)), 60+((20/9)*mouseY), 300+(10*sin(1+frameCount*0.04)));
  line(80+((20/9)*mouseY), 280+(10*sin(1+frameCount*0.04)), 90+((20/9)*mouseY), 310+(10*sin(1+frameCount*0.04)));
  line(90+((20/9)*mouseY), 310+(10*sin(1+frameCount*0.04)), 80+((20/9)*mouseY), 340+(10*sin(1+frameCount*0.04)));
  
  //right
  line(360+((20/9)*mouseY), 60+(10*sin(1.5+frameCount*0.04)), 340+((20/9)*mouseY), 100+(10*sin(1.5+frameCount*0.04)));
  line(340+((20/9)*mouseY), 100+(10*sin(1.5+frameCount*0.04)), 360+((20/9)*mouseY), 120+(10*sin(1.5+frameCount*0.04)));
  line(350+((20/9)*mouseY), 80+(10*sin(1.5+frameCount*0.04)), 380+((20/9)*mouseY), 100+(10*sin(1.5+frameCount*0.04)));
  line(360+((20/9)*mouseY), 120+(10*sin(1.5+frameCount*0.04)), 340+((20/9)*mouseY), 140+(10*sin(1.5+frameCount*0.04)));
  
  //lightning glow
  strokeWeight(10);
  
  //alpha shifts low and high
  stroke(100, 225, 255, millis() % 65);
  
  //left
  line(60+((20/9)*mouseY), 60+(10*sin(0.7+frameCount*0.04)), 40+((20/9)*mouseY), 80+(10*sin(0.7+frameCount*0.04)));
  line(40+((20/9)*mouseY), 80+(10*sin(0.7+frameCount*0.04)), 60+((20/9)*mouseY), 100+(10*sin(0.7+frameCount*0.04)));
  line(60+((20/9)*mouseY), 100+(10*sin(0.7+frameCount*0.04)), 20+((20/9)*mouseY), 120+(10*sin(0.7+frameCount*0.04)));
  line(40+((20/9)*mouseY), 110+(10*sin(0.7+frameCount*0.04)), 60+((20/9)*mouseY), 120+(10*sin(0.7+frameCount*0.04)));
  line(60+((20/9)*mouseY), 120+(10*sin(0.7+frameCount*0.04)), 50+((20/9)*mouseY), 140+(10*sin(0.7+frameCount*0.04)));
  
  //center
  line(240+((20/9)*mouseY), 60+(10*sin(1+frameCount*0.04)), 220+((20/9)*mouseY), 80+(10*sin(1+frameCount*0.04)));
  line(220+((20/9)*mouseY), 80+(10*sin(1+frameCount*0.04)), 210+((20/9)*mouseY), 100+(10*sin(1+frameCount*0.04)));
  line(210+((20/9)*mouseY), 100+(10*sin(1+frameCount*0.04)), 230+((20/9)*mouseY), 120+(10*sin(1+frameCount*0.04)));
  line(230+((20/9)*mouseY), 120+(10*sin(1+frameCount*0.04)), 220+((20/9)*mouseY), 160+(10*sin(1+frameCount*0.04)));
  line(220+((20/9)*mouseY), 160+(10*sin(1+frameCount*0.04)), 260+((20/9)*mouseY), 220+(10*sin(1+frameCount*0.04)));
  line(260+((20/9)*mouseY), 220+(10*sin(1+frameCount*0.04)), 300+((20/9)*mouseY), 240+(10*sin(1+frameCount*0.04)));
  line(300+((20/9)*mouseY), 240+(10*sin(1+frameCount*0.04)), 310+((20/9)*mouseY), 260+(10*sin(1+frameCount*0.04)));
  
  line(260+((20/9)*mouseY), 220+(10*sin(1+frameCount*0.04)), 280+((20/9)*mouseY), 260+(10*sin(1+frameCount*0.04)));
  line(280+((20/9)*mouseY), 260+(10*sin(1+frameCount*0.04)), 270+((20/9)*mouseY), 280+(10*sin(1+frameCount*0.04)));
  
  line(210+((20/9)*mouseY), 100+(10*sin(1+frameCount*0.04)), 190+((20/9)*mouseY), 120+(10*sin(1+frameCount*0.04)));
  line(190+((20/9)*mouseY), 120+(10*sin(1+frameCount*0.04)), 180+((20/9)*mouseY), 140+(10*sin(1+frameCount*0.04)));
  line(180+((20/9)*mouseY), 140+(10*sin(1+frameCount*0.04)), 140+((20/9)*mouseY), 180+(10*sin(1+frameCount*0.04)));
  line(140+((20/9)*mouseY), 180+(10*sin(1+frameCount*0.04)), 120+((20/9)*mouseY), 240+(10*sin(1+frameCount*0.04)));
  line(120+((20/9)*mouseY), 240+(10*sin(1+frameCount*0.04)), 60+((20/9)*mouseY), 300+(10*sin(1+frameCount*0.04)));
  line(80+((20/9)*mouseY), 280+(10*sin(1+frameCount*0.04)), 90+((20/9)*mouseY), 310+(10*sin(1+frameCount*0.04)));
  line(90+((20/9)*mouseY), 310+(10*sin(1+frameCount*0.04)), 80+((20/9)*mouseY), 340+(10*sin(1+frameCount*0.04)));
  
  //right
  line(360+((20/9)*mouseY), 60+(10*sin(1.5+frameCount*0.04)), 340+((20/9)*mouseY), 100+(10*sin(1.5+frameCount*0.04)));
  line(340+((20/9)*mouseY), 100+(10*sin(1.5+frameCount*0.04)), 360+((20/9)*mouseY), 120+(10*sin(1.5+frameCount*0.04)));
  line(350+((20/9)*mouseY), 80+(10*sin(1.5+frameCount*0.04)), 380+((20/9)*mouseY), 100+(10*sin(1.5+frameCount*0.04)));
  line(360+((20/9)*mouseY), 120+(10*sin(1.5+frameCount*0.04)), 340+((20/9)*mouseY), 140+(10*sin(1.5+frameCount*0.04)));
  
  //end
  noStroke();
  
}

void draw()  {
  
  //set stroke weight
  strokeWeight(7);
  
  //make sure framerate is 60
  frameRate(60);
  
  //background
  background(45+mouseY/20, 45+mouseY/45, 50+mouseY/45); //will shift from dark to light
  fill(225, 125, 25, 10); //gradient shading fill
  
  //top gradient
  rect(0, 0, 400, 40-10*cos(frameCount*0.04));
  rect(0, 0, 400, 80-10*cos(0.5+frameCount*0.04));
  rect(0, 0, 400, 120-10*cos(1+frameCount*0.04));
  rect(0, 0, 400, 160-10*cos(1.5+frameCount*0.04));
  
  //bottom gradient
  rect(0, 360-10*sin(frameCount*0.04), 400, 40+10*sin(frameCount*0.04));
  rect(0, 320-10*sin(0.5+frameCount*0.04), 400, 80+10*sin(0.5+frameCount*0.04));
  rect(0, 280-10*sin(1+frameCount*0.04), 400, 120+10*sin(1+frameCount*0.04));
  rect(0, 240-10*sin(1.5+frameCount*0.04), 400, 160+10*sin(1.5+frameCount*0.04));
  
  /* SUN */
  
  //center
  fill(225, 140, 100);
  ellipse(320+(25*sin(mouseY*0.011)), 500-mouseY, 50, 50);
  
  //glow
  fill(255, 180, 100, 25);
  ellipse(320+(25*sin(mouseY*0.011)), 500-mouseY, 70+(4*sin(frameCount*0.04)), 70+(4*sin(frameCount*0.04)));
  ellipse(320+(25*sin(mouseY*0.011)), 500-mouseY, 60+(4*sin(0.5+frameCount*0.04)), 60+(4*sin(0.5+frameCount*0.04)));
  ellipse(320+(25*sin(mouseY*0.011)), 500-mouseY, 80+(4*sin(1+frameCount*0.04)), 80+(4*sin(1+frameCount*0.04)));
  ellipse(320+(25*sin(mouseY*0.011)), 500-mouseY, 110+(4*sin(1.5+frameCount*0.04)), 110+(4*sin(1.5+frameCount*0.04)));
  ellipse(320+(25*sin(mouseY*0.011)), 500-mouseY, 140+(4*sin(2+frameCount*0.04)), 140+(4*sin(2+frameCount*0.04)));
  
  /* RED AURA */
  
  //left
  fill(150, 25, 20, 25+(15*sin(frameCount*0.04)));
  ellipse(0, 420+mouseY, 300+(4*sin(frameCount*0.04)), 300+(4*sin(frameCount*0.04)));
  ellipse(0, 420+mouseY, 320+(4*sin(0.5+frameCount*0.04)), 320+(4*sin(0.5+frameCount*0.04)));
  ellipse(0, 420+mouseY, 340+(4*sin(1+frameCount*0.04)), 340+(4*sin(1+frameCount*0.04)));
  
  //right
  ellipse(400, 420+mouseY, 300+(4*sin(frameCount*0.04)), 300+(4*sin(frameCount*0.04)));
  ellipse(400, 420+mouseY, 320+(4*sin(0.5+frameCount*0.04)), 320+(4*sin(0.5+frameCount*0.04)));
  ellipse(400, 420+mouseY, 340+(4*sin(1+frameCount*0.04)), 340+(4*sin(1+frameCount*0.04)));
  
  //center
  ellipse(200, 420+mouseY, 200+(4*sin(frameCount*0.04)), 200+(4*sin(frameCount*0.04)));
  ellipse(200, 420+mouseY, 220+(4*sin(0.5+frameCount*0.04)), 220+(4*sin(0.5+frameCount*0.04)));
  ellipse(200, 420+mouseY, 240+(4*sin(1+frameCount*0.04)), 240+(4*sin(1+frameCount*0.04)));
  
  /*FACE*/
  
  //eyeglow
  fill(255, 60, 0, 40-(mouseY/1.57));
  ellipse(80+((mouseX+65)/10), 160+((mouseY-45)/20), 50+5*sin(frameCount*0.04), 50+5*sin(frameCount*0.04)); //left
  ellipse(260+((mouseX+65)/10), 160+((mouseY-45)/20), 50+5*sin(frameCount*0.04), 50+5*sin(frameCount*0.04)); //right
  
  ellipse(80+((mouseX+65)/10), 160+((mouseY-45)/20), 40+5*sin(0.5+frameCount*0.04), 40+5*sin(0.5+frameCount*0.04)); //left
  ellipse(260+((mouseX+65)/10), 160+((mouseY-45)/20), 40+5*sin(0.5+frameCount*0.04), 40+5*sin(0.5+frameCount*0.04)); //right
  
  noFill();
  
  //eyes
  stroke(255-(mouseY/1.57), 120-(mouseY/20), 45+(mouseY/25));
  ellipse(80+((mouseX+65)/10), 160+((mouseY-45)/20), 25, 25); //left
  ellipse(260+((mouseX+65)/10), 160+((mouseY-45)/20), 25, 25); //right
  
  //mouth
  arc(200+(mouseX/40), 200+(mouseY/40), 140, 140, QUARTER_PI, HALF_PI+QUARTER_PI);
  
  //eyebrows
  arc(100+(mouseX/26.67), 200+(mouseY/40), 120, 120, PI+QUARTER_PI, PI+HALF_PI+QUARTER_PI); //left
  arc(280+(mouseX/26.67), 200+(mouseY/40), 120, 120, PI+QUARTER_PI, PI+HALF_PI+QUARTER_PI); //right
  
  //cheeks
  arc(120+(mouseX/40), 200+(mouseY/40), 200, 200, HALF_PI+QUARTER_PI, PI+QUARTER_PI); //left
  arc(280+(mouseX/40), 200+(mouseY/40), 200, 200, PI+HALF_PI+QUARTER_PI, TWO_PI+QUARTER_PI); //right
  
  //nose
  line(200+(mouseX/26.67), 160+(mouseY/26.67), 200+(mouseX/26.67), 200+(mouseY/26.67)); //the bridge
  ellipse(200+(mouseX/26.67), 220+(mouseY/26.67), 40, 40); //the smell sponge
  
  fill(45+mouseY/20, 45+mouseY/45, 50+mouseY/45);
  stroke(45+mouseY/20, 45+mouseY/45, 50+mouseY/45);
  rect(170+(mouseX/26.67), 190+(mouseY/26.67), 23, 30); //the sponge block
  
  /*CLOUDS*/
  
  noStroke();
  
  //bottom layer
  fill(35, 35, 45, 255-mouseY/4);
  ellipse(((20/9)*mouseY)+60, -20+(10*sin(0.7+frameCount*0.04)), 160, 160);
  ellipse(((-20/9)*mouseY)+340, 420-(10*sin(2.2+frameCount*0.04)), 160, 160);
  
  ellipse(((20/9)*mouseY)+180, -20+(10*sin(1.2+frameCount*0.04)), 160, 160);
  ellipse(((-20/9)*mouseY)+220, 420-(10*sin(1.7+frameCount*0.04)), 160, 160);
  
  ellipse(((20/9)*mouseY)+300, -20+(10*sin(1.7+frameCount*0.04)), 160, 160);
  ellipse(((-20/9)*mouseY)+100, 420-(10*sin(1.2+frameCount*0.04)), 160, 160);
  
  ellipse(((20/9)*mouseY)+420, -20+(10*sin(2.2+frameCount*0.04)), 160, 160);
  ellipse(((-20/9)*mouseY)-20, 420-(10*sin(0.7+frameCount*0.04)), 160, 160);
  
  
  //middle layer
  fill(25, 25, 35, 255-mouseY/4);
  ellipse(((20/9)*mouseY), -20+(10*sin(frameCount*0.04)), 160, 160);
  ellipse(((-20/9)*mouseY)+400, 420-(8*sin(1.5+frameCount*0.04)), 160, 160);
  
  ellipse(((20/9)*mouseY)+120, -20+(10*sin(0.5+frameCount*0.04)), 160, 160);
  ellipse(((-20/9)*mouseY)+280, 420-(8*sin(1+frameCount*0.04)), 160, 160);
  
  ellipse(((20/9)*mouseY)+240, -20+(10*sin(1+frameCount*0.04)), 160, 160);
  ellipse(((-20/9)*mouseY)+160, 420-(8*sin(0.5+frameCount*0.04)), 160, 160);
  
  ellipse(((20/9)*mouseY)+360, -20+(10*sin(1.5+frameCount*0.04)), 160, 160);
  ellipse(((-20/9)*mouseY)+40, 420-(8*sin(frameCount*0.04)), 160, 160);
  
  //top layer
  fill(15, 15, 25, 255-mouseY/4);
  ellipse(((20/9)*mouseY)+60, -40+(10*sin(frameCount*0.04)), 160, 160);
  ellipse(((-20/9)*mouseY)+400, 440-(7*sin(1.5+frameCount*0.04)), 160, 160);
  
  ellipse(((20/9)*mouseY)+180, -40+(10*sin(0.5+frameCount*0.04)), 160, 160);
  ellipse(((-20/9)*mouseY)+280, 440-(7*sin(1+frameCount*0.04)), 160, 160);
  
  ellipse(((20/9)*mouseY)+300, -40+(10*sin(1+frameCount*0.04)), 160, 160);
  ellipse(((-20/9)*mouseY)+160, 440-(7*sin(0.5+frameCount*0.04)), 160, 160);
  
  ellipse(((20/9)*mouseY)+420, -40+(10*sin(1.5+frameCount*0.04)), 160, 160);
  ellipse(((-20/9)*mouseY)+40, 440-(7*sin(frameCount*0.04)), 160, 160);
}