//Sean B. Leo
//sleo@andrew.cmu.edu
//Section C
//Project_02
var eyeSize = 20;
var pupil = 10;
var faceWidth = 100;
var faceHeight = 150;
var red = ("red");
var green = ("green");
var blue = ("blue");
var r1 = 255;
var g1 = 255;
var b1 = 255;
var r2 = 255;
var g2 = 255;
var b2 = 255;
var A = 20;
var B = 40;
var C = 1;
function setup() {
createCanvas(600, 500);
}
function draw() {
background(red, green, blue);
let c = color(255, 255, 255);
//body
fill(r2, g2, b2);
ellipse(width/2, height/2 + faceHeight, faceWidth + (faceWidth/2), faceHeight + (faceHeight/2));
//ellipse((width / 2) + faceWidth, (height / 2) + faceHieght, faceWidth * 2, faceHeight * 2);
//head
fill(r1, g1, b1),
ellipse(width / 2, height / 2, faceWidth, faceHeight);
//eyes
fill(255);
var eyeHeightLX = (height/2);
var eyeHeightRX = (height/2);
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);
//pupils
fill(0);
ellipse(eyeLX, eyeHeightLX, pupil, pupil);
ellipse(eyeRX, eyeHeightRX, pupil, pupil);
//eyebrows
{strokeWeight(3);
var eyeBrowLH1 = eyeHeightLX-pupil*2;
var eyeBrowLH2 = eyeHeightLX-pupil*C;
var eyeBrowRH1 = eyeHeightRX-pupil*C;
var eyeBrowRH2 = eyeHeightRX-pupil*2;
line(eyeLX-pupil, eyeBrowLH1, eyeLX+pupil, eyeBrowLH2);
line(eyeRX-pupil, eyeBrowRH1, eyeRX+pupil, eyeBrowRH2);
}
//mouth
fill(0);
var mouthHeight=height/2 + faceHeight *.30;
ellipse(width/2, mouthHeight, B, 20);
//nose
fill(r1, g1, b1);
arc(width/2, height/2 + faceHeight*.09, A, A, C, PI + QUARTER_PI, OPEN);
}
function mousePressed() {
red = random(0,255);
green = random(0, 255);
blue = random(0, 255);
r1 = random(20, 255);
g1 = random(20, 255);
b1 = random(20, 255);
r2 = random(0, 255);
g2 = random(0, 255);
b2 = random(0, 255);
A = random(1,30);
B = random(1,40);
C = random(1,3);
faceWidth = random(75, 250);
faceHeight = random(75, 250);
eyeSize = random(10, 30);
pupil = random(7, 12);
}
A big part of figuring out this project was trying to wrap my head around what was spatially dependent on what. It was easier to think of things modularly; if the eyebrow is linked to the eye and if the eye is linked to the head, if the head changes everything else will follow.