//Monica Chang
//Section D
//mjchang@andrew.cmu.edu
//Project-02
var eyeSize = 40;
var faceWidth = 200;
var faceHeight = 250;
var wow = 50;
var pupil = 30;
var hairY = 100;
var body = 40
var colorChange = 0;
function setup() {
createCanvas(640, 480);
}
function draw() {
noStroke(0)
background("tan");
//body
fill(141- colorChange,180- colorChange,180- colorChange);
quad(body,height,width/4.5,height*.72,width-170,height*.72,width-body,height);
//face
fill(251,197,177);
ellipse(width / 2, height / 2, faceWidth, faceHeight);
//eyes
var eyeLX = width / 2 - faceWidth * 0.25;
var eyeRX = width / 2 + faceWidth * 0.25;
fill("peach");
ellipse(eyeLX, height / 2.15, eyeSize, eyeSize);
ellipse(eyeRX, height / 2.15, eyeSize, eyeSize);
//mouth
fill("red");
arc(width / 2, height / 2, wow, wow, TWO_PI, PI);
//pupil
fill("blue");
ellipse(eyeLX, height / 2.15, pupil, pupil);
ellipse(eyeRX, height / 2.15, pupil, pupil);
//hair
fill("black");
strokeWeight(3);
stroke (254);
line( width / 2, height/ 3.5 , width / 2 , hairY );
line( (width / 2)/1.1, height/ 3.5 , (width / 2)/1.1 , hairY + 10 );
line( (width / 2)*1.1, height/ 3.5 , (width / 2)*1.1 , hairY + 10 );
}
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.
faceWidth = random(200, 350);
faceHeight = random(200, 250);
eyeSize = random(40, 60);
wow = random(10,50);
pupil = random(10,30);
hairY = random(100,180);
colorChange = random (0,180);
}
This was a very entertaining project to do, I noticed that variables do make it easier to organize the values in such a way that I would not get confused. A whole field of numbers would, indeed, give me a headache so it was interesting to play around with variables and get used to how they can simplify code.