In this exercise, I tried to present a life cycle from young age to old. The three aspects of variability are the color of the hair, movement of the ears, and the size of the face.
//Jacky Tian
//Section B
//yinjiet@andrew.cmu.edu
//project-01
function setup() {
createCanvas(480, 640);
}
var x1 = 175;
var y1 = 320;
var x2 = 425;
var y2 = 320;
var count = 0;
var eyecolor = 0;
var facew = 250;
function draw() {
background(220);
strokeWeight(1);
stroke(0, 0, 0);
fill(236, 212, 190);
ellipse(x2, y1, 25, 50);
ellipse(x1, y1, 25, 50);
strokeWeight(0);
stroke(0, 0, 0);
fill(236, 212, 190);
rect(270, 460, 60, 60),
strokeWeight(0);
stroke(0, 0, 0);
fill(236, 212, 190);
ellipse(300, 320, facew, 300);
fill(eyecolor)
quad(175, 270, 280, 270, 308, 160, 210, 185);
quad(320, 270, 425, 270, 390, 185, 292, 160);
strokeWeight(4);
stroke(212, 175, 55);
fill(255);
rect(200, 275, 80, 60);
rect(320, 275, 80, 60);
line(280, 300, 320, 300);
line(175, 285, 200, 300);
line(425, 285, 400, 300);
strokeWeight(1);
stroke(0, 0, 0);
fill(236, 212, 190);
triangle(300, 350, 290, 375, 310, 375);
strokeWeight(1);
stroke(0, 0, 0);
noFill();
arc(300, 415, 80, 80, 0, PI + QUARTER_PI, OPEN);
stroke(0, 0, 0);
fill(0, 0, 0);
quad(200, 520, 400, 520, 500, 600, 100, 600);
stroke(0, 0, 0);
fill(51);
rect(200, 580, 80, 100);
}
function mousePressed() {
// when the user clicks, these variables are reassigned
// to random values within specified ranges. For example,
// 'faceWidth' gets a random value between 75 and 150.
if(count % 2 == 0){
y1 -= 10;
}else{
y1 += 10;
}
eyecolor += 15;
eyecolor = eyecolor % 255
count += 1;
facew -= 5;
// x1 = x1 - 5;
// x2 = x2 + 5;
}