var hairColor = "black"
var cheekHeight = 160;
var cheekWidth = 160;
var jawHeight = 320;
var jawWidth = 160;
var chinY = jawHeight+100;
var chinX = 320;
var skin = (229,160,115);
var eyeWidth = 64;
var squint = 24;
var eyeBLX = 320-cheekWidth/2;
var eyeBY = cheekHeight;
var eyeBRX = eyeBLX+cheekWidth;
var eyeY = eyeBY +50 ;
var eyeLX = eyeBLX;
var eyeRX = eyeBRX;
var eyeSize = 75;
var irisSize = eyeSize/2;
var pupilSize = irisSize/4;
var eyeColor = "blue"
var noseWidth=25;
var noseLength=80;
var nostrilWidth = noseWidth+20
var mouthHeight = jawHeight
var mouthWidth = jawWidth - 60
var lipsize = 10
function setup() {
createCanvas(640, 480);
}
function draw() {
background(180,23,230);
//noStroke();
strokeWeight(3);
//hair
fill(hairColor);
ellipse(width/2,height/2,500,500);
fill(skin);
beginShape();
curveVertex(width/4,100);
curveVertex(width/4,100);//left temple
curveVertex(cheekWidth,cheekHeight);
curveVertex(jawWidth, jawHeight);
curveVertex(chinX,chinY);
curveVertex((width-jawWidth),jawHeight);
curveVertex((width-cheekWidth),cheekHeight);
curveVertex(width-(width/4),100);
curveVertex(width-(width/4),100);//right temple
endShape();
//eyebrows
fill(hairColor);
beginShape();
vertex(eyeBLX-eyeWidth,eyeBY);
bezierVertex(eyeBLX,eyeBY,eyeBLX+(eyeWidth/2),eyeBY+squint,eyeBLX+eyeWidth,eyeBY);
bezierVertex(eyeBLX,eyeBY,eyeBLX+(eyeWidth/2),eyeBY-squint,eyeBLX-eyeWidth,eyeBY);
endShape();
beginShape();
vertex(eyeBRX-eyeWidth,eyeBY);
bezierVertex(eyeBRX, eyeBY, eyeBRX+(eyeWidth/2),eyeBY-squint,eyeBRX+eyeWidth,eyeBY);
bezierVertex(eyeBRX,eyeBY,eyeBRX+(eyeWidth/2),eyeBY+squint, eyeBRX-eyeWidth,eyeBY);
endShape();
//eyes
fill("white"); //eyeball
ellipse(eyeLX,eyeY,eyeSize*1.2,irisSize);
ellipse(eyeRX,eyeY,eyeSize*1.2,irisSize);
fill(eyeColor); //iris
ellipse(eyeLX,eyeY, irisSize, irisSize);
ellipse(eyeRX, eyeY,irisSize,irisSize);
fill("black");//pupils
ellipse(eyeLX,eyeY, pupilSize, pupilSize);
ellipse(eyeRX,eyeY,pupilSize,pupilSize);
//nose
strokeWeight(2);
fill(skin);
beginShape();
curveVertex(noseWidth+(width/2),cheekHeight+30);
curveVertex(noseWidth+(width/2),cheekHeight+30);
curveVertex((width/2)+nostrilWidth,cheekHeight+noseLength+30);
curveVertex((width/2)+noseWidth, cheekHeight+noseLength+30);
curveVertex(width/2,noseLength+cheekHeight+40);
curveVertex((width/2)-noseWidth,noseLength + cheekHeight+30);
curveVertex((width/2)-nostrilWidth,noseLength + cheekHeight+30);
curveVertex((width/2)-noseWidth,cheekHeight+30);
curveVertex((width/2)-noseWidth,cheekHeight+30);
endShape();
//mouth
fill(255,10,10);
beginShape(); //lower lip
curveVertex((width/2)-mouthWidth,mouthHeight);
curveVertex((width/2)-mouthWidth,mouthHeight);
curveVertex((width/2)-(mouthWidth/2),mouthHeight+(lipsize/2));
curveVertex(width/2, mouthHeight+lipsize);
curveVertex((width/2)+(mouthWidth/2),mouthHeight+(lipsize/2));
curveVertex((width/2)+mouthWidth,mouthHeight);
curveVertex((width/2)+mouthWidth,mouthHeight);
//upper lip
curveVertex((width/2)-mouthWidth,mouthHeight);
curveVertex((width/2)-mouthWidth,mouthHeight);
curveVertex((width/2)-(mouthWidth/2), mouthHeight-(lipsize));
curveVertex(width/2,mouthHeight-lipsize);
curveVertex((width/2)+(mouthWidth/2), mouthHeight-(lipsize));
curveVertex((width/2)+mouthWidth,mouthHeight);
curveVertex((width/2)+mouthWidth,mouthHeight);
endShape();
}
function mousePressed() {
cheekHeight = height/3 + random(-20,20);
cheekWidth = width/4 + random(-20,20);
jawHeight = (height/4) + random(150,200);
jawWidth = (width/4) + random(0,100);
chinY = jawHeight+random(100,200);
eyeWidth = width/10 + random(0,25);
squint = height/20 + random(-20,20);
eyeBY = cheekHeight + random(-10,10);
eyeBRX = eyeBLX + cheekWidth + random(-10,10);
hairColor = (random(0,255),random(0,255),random(0,255));
eyeY = eyeBY + random(30,75);
eyeSize = random(40, 100);
irisSize = random((eyeSize/2), eyeSize/10);
//pupilSize = ranodom((irisSize/4),irisSize/20);
eyeColor = ((random(0,255),random(0,255),random(0,355)));
noseWidth = random(10,40);
noseLength = random(10,100);
nostrilWidth = noseWidth + random(10,40);
mouthHeight = jawHeight + random(20,100);
mouthWidth = random(10,90);
// lipSize = random(5,20);
skin = random("chocolate", "coral", "khaki","LightSalmon", "moccasin");
}
Upon doing this project, I realized that I had issues with scaling things in the way that I wanted them. In order to correct that, I utilized the randomized feature to click through facial features that would fit and not fit. Eventually, I decided to have my faces look comedic more than anything else. I also had trouble with randomizing colors.