/*
Eliza Pratt
Section E
elpratt@andrew.cmu.edu
Project-02
*/
var eyeSize = 30;
var eyeWidth = 1;
var blu = 100;
var faceWidth = 250;
var faceHeight = 300;
var skin = 30;
var glasses = 20;
var cut = 120;
var brow = 0;
function setup() {
createCanvas(640, 480);
}
function draw() {
noStroke();
background(200, 222, 230);
//hair
fill(224, 72, 72);
rect(width / 2 - faceWidth/2 - 20, height / 2 - 45, faceWidth + 40, cut, 0, 0, 10, 10);
fill('rgba(0,0,0, 0.25)');
rect(width / 2 - faceWidth/2, height / 2 - 45, faceWidth, cut);
////////HEAD/////////
fill(242-skin, 194-skin, 131-skin);
//ears
ellipse(width/2 - faceWidth/2, height/2 + 10, 55, 65);
ellipse(width/2 + faceWidth/2, height/2 + 10, 55, 65);
fill('rgba(0,0,0, 0.25)');
ellipse(width/2 - faceWidth/2, height/2 + 12, 35, 45);
ellipse(width/2 + faceWidth/2, height/2 + 12, 35, 45);
//neck
fill(242-skin, 194-skin, 131-skin);
rect(width/2 - 25, height/2 + faceHeight/3, faceWidth/5, faceHeight + 50);
beginShape();
curveVertex(width/2 - faceWidth/3, 600);
curveVertex(width/2 - faceWidth/3, 480);
curveVertex(width/2, height*0.8);
curveVertex(width/2 + faceWidth/3, 480);
curveVertex(width/2 + faceWidth/3, 600);
endShape();
//face
ellipse(width / 2, height / 2, faceWidth, faceHeight);
////////NOSE////////
noFill();
stroke('rgba(0,0,0, 0.25)');
var noseLine = height/2 + 40;
beginShape();
curveVertex(width/2 - 20, noseLine);
curveVertex(width/2 - 20, noseLine);
curveVertex(width/2, noseLine + 10);
curveVertex(width/2 + 20, noseLine);
curveVertex(width/2 + 20, noseLine);
endShape();
////////////EYES//////////
var eyeLX = width / 2 - faceWidth * 0.25;
var eyeRX = width / 2 + faceWidth * 0.25;
//eyes
fill(255);
ellipse(eyeLX, height / 2, eyeSize*eyeWidth, eyeSize);
ellipse(eyeRX, height / 2, eyeSize*eyeWidth, eyeSize);
//irises
fill(26, blu, 138);
stroke(0);
strokeWeight(3);
ellipse(eyeLX, height / 2, eyeSize/2, eyeSize/2);
ellipse(eyeRX, height / 2, eyeSize/2, eyeSize/2);
//pupilS
fill(0);
ellipse(eyeLX, height / 2, eyeSize/5, eyeSize/5);
ellipse(eyeRX, height / 2, eyeSize/5, eyeSize/5);
//reflection
fill(255);
noStroke();
ellipse(eyeLX + 3, 1 + height / 2, eyeSize/5, eyeSize/5);
ellipse(eyeRX + 3, 1 + height / 2, eyeSize/5, eyeSize/5);
//eyelids
fill(242-skin, 194-skin*1.5, 131-skin);
stroke(0);
strokeWeight(3);
arc(eyeLX, height / 2, eyeSize*eyeWidth, eyeSize, PI, 0, CHORD);
arc(eyeRX, height / 2, eyeSize*eyeWidth, eyeSize, PI, 0, CHORD);
////////EYEBROWS////////
noFill();
stroke(224, 72, 72);
strokeWeight(brow + 3);
if (brow < 1) {
arc(eyeLX, height/2 - 30, eyeSize + 30, 15, PI, 0);
arc(eyeRX, height/2 - 30, eyeSize + 30, 15, PI, 0);
}
else if (brow < 2) {
arc(eyeLX, height/2 - 30, eyeSize + 30, 15, 0, PI);
arc(eyeRX, height/2 - 30, eyeSize + 30, 15, PI, 0);
}
else if (brow < 3) {
arc(eyeLX, height/2 - 30, eyeSize + 30, 15, PI, 0);
arc(eyeRX, height/2 - 30, eyeSize + 30, 15, 0, PI);
}
else {
arc(eyeLX, height/2 - 30, eyeSize + 30, 15, 0, PI);
arc(eyeRX, height/2 - 30, eyeSize + 30, 15, 0, PI);
}
///////GLASSES////////
noFill();
stroke(0);
strokeWeight(3);
rect(width/2 - 120 , height/2 - 25, 100, 60, glasses);
rect(width/2 + 20, height/2 - 25, 100, 60, glasses);
line(width/2 - 20, height/2 - 10, width/2 + 20, height/2 - 10);
/////////MOUTH/////////
noStroke();
var lipLine = height/2 + faceHeight/4;
//upper lip
fill(92,13,58);
arc(width/2 - 10, lipLine, 30, 25, PI, 0);
arc(width/2 + 10, lipLine, 30, 25, PI, 0);
//bottom lip
fill(155, 0, 55);
arc(width/2, lipLine, 50, 40, 0, PI);
///////BANGS///////////
noStroke();
fill(224, 72, 72);
var hair = height/3;
arc(width / 2, height / 2 - 45, faceWidth + 40, faceHeight, PI, 0);
/////SHIRT///////
fill(40, 16, blu);
rect(width/2 - faceWidth/3, height*0.85, 2*faceWidth/3, 100, 20);
fill(242-skin, 194-skin, 131-skin);
arc(width/2, height*0.85, 80, 30, 0, PI);
}
function mousePressed() {
eyeSize = random(30, 40);
eyeWidth = random(1,2);
blu = random(0,255);
skin = random(1, 100);
glasses = random(1, 50);
cut = random(90, 260);
brow = random(4);
}
With this project, I had a lot of fun messing with the sizes, colors, and shapes of different features. In fact, I had to restrain myself from making every object changeable for the sake of time. I also spent a solid chunk of my afternoon trying to get the eyes to move with the mouse before giving up out of frustration. Maybe next time?