//Alexander Chen
//Section A
//alchen1@andrew.cmu.edu
//Project_02
var faceWidth = 100;
var faceHeight = 150;
var eyeSize = 20;
var pupilColor = 255;
var eyeColorR = 0
var eyeColorG = 0
var eyeColorB = 0
var earWidth = 10
var earHeight = 20
var mouthSize = 20
var hairHeight = 40
function setup() {
createCanvas(640, 480);
}
function draw() {
background(242, 126, 159);
//FACE//
noStroke();
fill(231, 175, 132);
ellipse(width / 2, height / 2, faceWidth, faceHeight);
//HAIR
fill(0)
var hairX = width / 2 - faceWidth / 2
var hairY = height / 2 - faceHeight / 2
var hairWidth = faceWidth
rect(hairX, hairY, hairWidth, hairHeight, 20, 20, 10, 10);
//EYES//
//eyes color
fill(pupilColor)
//pupil size + location
var eyeLX = width / 2 - faceWidth * 0.25;
var eyeRX = width / 2 + faceWidth * 0.25;
ellipse(eyeLX, height / 2, eyeSize, eyeSize);
ellipse(eyeRX, height / 2, eyeSize, eyeSize);
//iris
fill(eyeColorR, eyeColorG, eyeColorB)
ellipse(eyeLX, height / 2, eyeSize / 2, eyeSize / 2);
ellipse(eyeRX, height / 2, eyeSize / 2, eyeSize / 2);
//EARS//
fill(231, 175, 132);
var earL = width / 2 - faceWidth / 2
var earR = width / 2 + faceWidth / 2
ellipse(earL, height / 2, earWidth, earHeight);
ellipse(earR, height / 2, earWidth, earHeight);
//NOSE//
fill(100, 75, 46)
rect(width / 2 - eyeSize / 4, height / 2, eyeSize / 2, eyeSize, 20)
//MOUTH//
fill(251, 62, 58)
ellipse(width / 2, height / 2 + faceHeight / 4, mouthSize, mouthSize)
}
function mousePressed() {
faceWidth = random(75, 150);
faceHeight = random(100, 150);
eyeSize = random(10, 30);
earWidth = random(5, 15);
earHeight = random(10, 20);
eyeColorR = random(0, 255);
eyeColorG = random(0, 255);
eyeColorb = random(0, 255);
mouthSize = random(10, 20);
}
This project was definitely a bit easier to get started with the templates. However, it was still as hard as I thought it was going to be with the variables within the variables. As someone who loses track easily, I found myself being confused with which variables lined up with which.