/*
Growing Old - by Suraj Sirohi
Moving the mouse on Y-axis moves the character's head up and down. Moving the mouse on X-axis 'ages'
the character, making him older as the mose moves from left to right, the idea of aging is also being
represented by the number of candles on the cake and fading of colors here.
Pressing mouse button present a dialogue by the character.
*/
void setup(){
//Set the size of the canvas, 400x400 as instructed.
size(400,400);
}
void draw(){
//Fading the background color as the character grows old.
background(115,209 - mouseX * 0.1,224 - mouseX * 0.1);
noStroke();
//Lower body - Fade the color of the shirt and make the body grow wider as the character grows old.
fill(250 - mouseX * 0.1,104,96);
ellipse(200,350 - mouseX * 0.02,200 + mouseX * 0.05,250);
//Table - Fade the color of the table as mouse moves to the right.
fill(188 - mouseX * 0.1 ,140,91);
rectMode(CENTER);
rect(200,408,400,100);
//Hair====================
//Hair Back - slightly move the hair ball at the back of the head at the back up and down
// following the mouse on Y-axis.
// - Fade the color of hair and pull the hair line back as the character grows old.
fill(121 + mouseX * 0.25,66 + mouseX * 0.25,29+ mouseX * 0.25);
ellipse(200 + mouseX * 0.02,120 + mouseY * 0.01,150,100);
//Hair small - Slightly move the hair ball according to the mouse's movements.
ellipse(160 + mouseX * 0.005,140 + mouseY * 0.01,100,100);
//Ears=====================
// -Change the color of the ear as the character grows old
fill(234 + mouseX * 0.05,192 + mouseX * 0.05,156 - mouseX*0.1);
//- move the ear to the left when mouse goes to the right,
//and move the ear to right when the mouse goes to the left,
//to reveal more of the ear.
//Ear Left
ellipse(120 - mouseX * 0.01,200 + mouseY * 0.02,45 - mouseX * 0.04,40 - mouseY * 0.02);
//Ear Right
ellipse(285 - mouseX * 0.02,200 + mouseY * 0.02,45 - mouseX * 0.04,40 - mouseY * 0.02);
//HeadDark
fill(245,219, 163);
ellipse(200,200,180 - mouseX * 0.07,200 - mouseY * 0.02);
//Wide Beard
fill(121 + mouseX * 0.25,66 + mouseX * 0.25,29+ mouseX * 0.25, - 80 + mouseX * 0.5);
ellipse(200,200,180 - mouseX * 0.07,200 - mouseY * 0.02);
//Head Light
fill(245,219, 163);
ellipse(200,190 - mouseY * 0.01,161 - mouseX * 0.07,178 - mouseY * 0.02);
//Circular Beard
fill(121 + mouseX * 0.25,66 + mouseX * 0.25,29+ mouseX * 0.25, - 80 + mouseX * 0.5);
ellipse(200 + mouseX * 0.02,260 + mouseY * 0.01,90,60);
//Hair Front
fill(121+ mouseX * 0.25,66+ mouseX * 0.25,29+ mouseX * 0.25);
ellipse(200 + mouseX * 0.02,120 + mouseY * 0.01 - mouseX * 0.04,110 - mouseX * 0.1,80 - mouseX * 0.1);
//Eyebrows=================
//Fades as the character grows old.
noFill();
stroke(72+ mouseX * 0.3,37 + mouseX * 0.3,14 + mouseX * 0.3);
strokeWeight(11 + mouseY * 0.005 - mouseX * 0.01);
//Left eyebrows
arc(162 + mouseX * 0.03,162 + mouseY * 0.05,50,50, PI + 0.5 , 2*PI - 1 + mouseX * 0.001);
//Right eyebrows
arc(234 + mouseX * 0.03,162 + mouseY * 0.05,50,50, PI + 0.5 + 0.5 - mouseX * 0.001, 2*PI - 0.5);
//Mouth - gets wider as the character grows old.
stroke(211,132,79);
strokeWeight(4);
arc(200 + mouseX * 0.03,230 + mouseY * 0.03 + mouseX * 0.03, 40 + mouseX * 0.1,20, 2*PI + 0.5, 3 * PI - 0.5);
//Eyes follow the mouse
//Eyes======================
fill(255);
noStroke();
//Left Eye
ellipse(160 + mouseX * 0.04, 180 + mouseY * 0.05,30 - mouseX * 0.01,40 - mouseY * 0.02 - mouseX * 0.07);
//Right Eye
ellipse(235 + mouseX * 0.04, 180 + mouseY * 0.05,30 - mouseX * 0.01,40 - mouseY * 0.02 - mouseX * 0.07);
//Pupils
fill(0);
//Pupil Left
ellipse(155 + mouseX * 0.06,180 + mouseY * 0.05,15 - mouseX * 0.01,15 - mouseX * 0.02);
//Pupil Right
ellipse(230 + mouseX * 0.06,180 + mouseY * 0.05,15 - mouseX * 0.01,15 - mouseX * 0.02);
//Reflection - fades away as the character grows old.
fill(255);
//Left Reflection
ellipse(152 + mouseX * 0.06,175 + mouseY * 0.06,7 - mouseX * 0.02,7 -mouseX * 0.02);
//Right Reflection
ellipse(228 + mouseX * 0.06,175 + mouseY * 0.06,7 - mouseX * 0.02,7 - mouseX * 0.02);
//Nose======================
fill(245,170,141);
ellipse(200 + mouseX * 0.04,200 + mouseY * 0.04, 25,30 - mouseY * 0.02);
//Nose Shadow
fill(219, 137, 104, 180);
ellipse(200 + mouseX * 0.04,209 + mouseY * 0.04, 15,10 - mouseY * 0.02);
//Cheeks are just slightly pink ellipses with low opacity which decreases further as the mouse mvoes to the left.
//Cheeks====================
fill(240,169,143, 100 + mouseY * 0.1 - mouseX * 0.25);
//Left Cheek
ellipse(150 + mouseX * 0.02,220 + mouseY * 0.04,35,35 - mouseY * 0.02);
//Right Cheek
ellipse(245 + mouseX * 0.02,220 + mouseY * 0.04,35,35 - mouseY * 0.02);
//wrinkles - wrinkles appear as the character grows old, by increasing the opacity.
stroke(0,0,0, -14 + mouseX * 0.11);
strokeWeight(2);
noFill();
//Right Eye Wrinkle
arc(235 + mouseX * 0.04,190 + mouseY * 0.04,30,25, PI + 16, 2*PI + 16);
//Left Eye Wrinkle
arc(160 + mouseX * 0.04,190 + mouseY * 0.04,30,25, PI + 15.5, 2*PI + 15.5);
//Cake========================
rectMode(CORNER);
noStroke();
fill(206,139,203);
rect(128,342 ,145,30);
ellipse(200,375 ,160,40);
fill(229,188,227);
ellipse(200,340,160,45);
//Candle and Flames's opacity is driven by mouseX position, so as the mouse moves to the right, more candles appear on
//the cake
//Candles====================
fill(247,137,52);
rect(135,310, 8,30);
fill(247,137,52, mouseX);
rect(155,310,8,30);
fill(247,137,52, -50 + mouseX * 1);
rect(175,310, 8,30);
fill(247,137,52, -100 + mouseX * 1);
rect(195,310, 8,30);
fill(247,137,52, -150 + mouseX * 1);
rect(215,310, 8,30);
fill(247,137,52, -200 + mouseX * 1);
rect(235,310, 8,30);
fill(247,137,52, -240 + mouseX * 1);
rect(255,310, 8,30);
//Flames consist of two ellipses - outer(lighter) flame and inner (stronger) flame, their height changes with time.
//Flames===================
fill(255,200,0,120);
ellipse(139,292,14,30 + 4*sin(frameCount * 0.2));
fill(255,200,0);
ellipse(139,298,10,20 + 4*sin(frameCount * 0.2));
fill(255,200,0, -200 + mouseX);
ellipse(159,292,14,30 + 4*sin(frameCount * 0.2));
fill(255,200,0, mouseX);
ellipse(159,298,10,20 + 4*sin(frameCount * 0.2));
fill(255,200,0, -240 + mouseX);
ellipse(179,292,14,30 + 4*sin(frameCount * 0.2));
fill(255,200,0, -50 + mouseX);
ellipse(179,298,10,20 + 4*sin(frameCount * 0.2));
fill(255,200,0, -260 + mouseX);
ellipse(199,292,14,30 + 4*sin(frameCount * 0.2));
fill(255,200,0, -100 + mouseX);
ellipse(199,298,10,20 + 4*sin(frameCount * 0.2));
fill(255,200,0, -280 + mouseX);
ellipse(219,292,14,30 + 4*sin(frameCount * 0.2));
fill(255,200,0, -150 + mouseX);
ellipse(219,298,10,20 + 4*sin(frameCount * 0.2));
fill(255,200,0, -300 + mouseX);
ellipse(239,292,14,30 + 4*sin(frameCount * 0.2));
fill(255,200,0, -200 + mouseX);
ellipse(239,298,10,20 + 4*sin(frameCount * 0.2));
fill(255,200,0,-320 + mouseX);
ellipse(259,292,14,30 + 4*sin(frameCount * 0.2));
fill(255,200,0, -240 + mouseX);
ellipse(259,298,10,20 + 4*sin(frameCount * 0.2));
}
//Print a dialogue when mouse button is pressed
void mousePressed(){
println("");
println("I am " +(mouseX/5 + 3) + " years old and I love watching cartoons.");
}