This project shows variable faces of a girl.
sketchDownload
var eyeSizeX = 40;
var eyeSizeY = 20;
var faceWidth = 150;
var faceHeight = 200;
var noseLength = 20;
var noseWidth = 10;
var browHeight = 170;var browExpression = 4;var leftMouth = 170;var rightMouth = 230;var mouthHeight = 250;var mouthExpression = 260;
function setup() {
createCanvas(400, 400);
}
function draw() {
stroke(0);
strokeWeight(2);
if (mouseX < 0.5 * width) {
background(228, 228, 253); } else {
background(198, 226, 249); }
point (width / 2, height * 0.2);
point (width * 0.7, height * 0.3);
point (width * 0.75, height / 2);
point (width * 0.75, height * 0.8);
point (width * 0.25, height * 0.8);
point (width * 0.25, height / 2);
point (width * 0.3, height * 0.3);
fill(0, 0, 0);
beginShape();
curveVertex(width / 2, height * 0.2);
curveVertex(width / 2, height * 0.2);
curveVertex(width * 0.7, height * 0.3);
curveVertex(width * 0.75, height / 2);
curveVertex(width * 0.75, height * 0.8);
curveVertex(width * 0.25, height * 0.8);
curveVertex(width * 0.25, height / 2);
curveVertex(width * 0.3, height * 0.3);
curveVertex(width / 2, height * 0.2);
curveVertex(width / 2, height * 0.2);
endShape();
fill(227, 180, 171); ellipse((width / 2), (height / 2), faceWidth, faceHeight)
point (width / 2, height * 0.2);
point (width * 0.4, height * 0.35);
point (width * 0.3, height * 0.4);
point (width * 0.4, height * 0.25);
point (width / 2, height * 0.2);
point (width * 0.6, height * 0.35);
point (width * 0.7, height * 0.4);
point (width * 0.6, height * 0.25);
fill(0, 0, 0);
beginShape();
curveVertex(width / 2, height * 0.2);
curveVertex(width / 2, height * 0.2);
curveVertex(width * 0.4, height * 0.35);
curveVertex(width * 0.3, height * 0.4);
curveVertex(width * 0.4, height * 0.25);
curveVertex(width / 2, height * 0.2);
curveVertex(width / 2, height * 0.2);
endShape();
beginShape();
curveVertex(width / 2, height * 0.2);
curveVertex(width / 2, height * 0.2);
curveVertex(width * 0.6, height * 0.35);
curveVertex(width * 0.7, height * 0.4);
curveVertex(width * 0.6, height * 0.25);
curveVertex(width / 2, height * 0.2);
curveVertex(width / 2, height * 0.2);
endShape();
fill(255, 255, 255); var leftEyeX = width / 2 - faceWidth * 0.25; var rightEyeX = width / 2 + faceWidth * 0.25; var eyeIrisX = 20; ellipse(leftEyeX, height / 2, eyeSizeX, eyeSizeY);
ellipse(rightEyeX, height /2, eyeSizeX, eyeSizeY);
fill(149, 85, 73);
ellipse(leftEyeX, height / 2, eyeIrisX, eyeSizeY); ellipse(rightEyeX, height / 2, eyeIrisX, eyeSizeY); fill(0, 0, 0); ellipse (leftEyeX, height / 2, 10); ellipse (rightEyeX, height / 2, 10);
if (eyeSizeY > 20) {
fill(255, 255, 255);
ellipse((leftEyeX + 3), height / 2, 5);
ellipse((rightEyeX + 3), height / 2, 5);
}
noFill();
beginShape();
curveVertex(width / 2, height / 2 - noseLength);
curveVertex(width / 2, height / 2 - noseLength);
curveVertex(width / 2, height / 2);
curveVertex(width / 2 + noseWidth, height / 2 + noseLength);
curveVertex(width / 2, height / 2 + 25);
curveVertex(width / 2 - 5, height / 2 + noseLength);
endShape();
fill(152, 41, 41);
point(leftMouth, mouthHeight);
point(rightMouth, mouthHeight);
point(width / 2, mouthExpression);
fill(255, 255, 255);
beginShape();
curveVertex(leftMouth, mouthHeight);
curveVertex(leftMouth, mouthHeight);
curveVertex(rightMouth, mouthHeight);
curveVertex(width / 2, mouthExpression);
curveVertex(leftMouth, mouthHeight);
curveVertex(leftMouth, mouthHeight);
endShape();
if (mouthExpression > 260) {
strokeWeight(0);
fill(251, 195, 204);
ellipse(leftMouth - 10, mouthHeight - 20, 15);
ellipse(rightMouth + 10, mouthHeight - 20, 15);
strokeWeight(2);
}
strokeWeight(5);
var leftBrowFront = width / 2 - faceWidth * 0.15
var rightBrowFront = width / 2 + faceWidth * 0.15
point(leftBrowFront, browHeight);
point(leftBrowFront - 20, browHeight - browExpression);
point(leftBrowFront - 35, browHeight);
noFill();
beginShape();
curveVertex(leftBrowFront, browHeight);
curveVertex(leftBrowFront, browHeight);
curveVertex(leftBrowFront - 20, browHeight - browExpression);
curveVertex(leftBrowFront - 35, browHeight);
curveVertex(leftBrowFront - 35, browHeight);
endShape();
point(rightBrowFront, browHeight);
point(rightBrowFront + 20, browHeight - browExpression);
point(rightBrowFront + 35, browHeight);
noFill();
beginShape();
curveVertex(rightBrowFront, browHeight);
curveVertex(rightBrowFront, browHeight);
curveVertex(rightBrowFront + 20, browHeight - browExpression);
curveVertex(rightBrowFront + 35, browHeight);
curveVertex(rightBrowFront + 35, browHeight);
endShape();
strokeWeight(2);
}
function mousePressed() {
faceWidth = random(130, 170);
faceHeight = random(230, 160);
eyeSizeX = random(35, 45);
eyeSizeY = random(15, 25);
noseLength = random (15, 25);
noseWidth = random (5, 15);
browHeight = random (160, 180);
browExpression = random (0, 10);
leftMouth = random (160, 180);
rightMouth = random (220, 240);
mouthHeight = random (240, 260);
mouthExpression = random (230, 270);
}