// Face variables
var eyeSize = 30;
var faceWidth = 80;
var faceHeight = 125;
var noseSize = 335;
var earSize = 15;
var mouthSize = 345;
function setup() {
createCanvas(480, 600);
}
function draw() {
background('blue');
//hair
fill('brown');
ellipse(width / 2, height / 2 -20, faceWidth, faceHeight);
//face
fill(253, 228, 200);
ellipse(width / 2, height / 2, faceWidth, faceHeight);
fill('white');
//eyes
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('brown');
ellipse(eyeLX, height / 2, eyeSize * .25, eyeSize * .25);
ellipse(eyeRX, height / 2, eyeSize * .25, eyeSize * .25);
//nose
fill(253, 228, 200);
triangle(240, 320, 237, noseSize, 243, noseSize);
//mouth
arc(width / 2, mouthSize, 10, 10, 0, PI, OPEN);
//ears
ellipse(240 - faceWidth * .5, 285, 10, earSize);
ellipse(240 + faceWidth * .5, 285, 10, earSize);
}
function mousePressed() {
faceWidth = random(70, 125);
faceHeight = random(120, 160);
eyeSize = random(18, 37);
noseSize = random(330, 340);
earSize = random(12, 18);
mouthSize = random(343, 348)
}
I had trouble with variables at first, but once I understood them more it was fine.