Christine Chen-Project-02-Variable-Face
/*
Christine Chen
Section E
cyc1@andrew.cmu.edu
Project-02-Variable-Face
*/
var faceWidth = 200;
var faceHeight = 200;
var eyeSize = 20;
var noseWidth = 20;
var noseHeight = 40;
var noseColorR = 94;
var noseColorG = 135;
var noseColorB = 191;
var mouthSize = 20;
function setup() {
createCanvas(640, 480);
}
function draw() {
background(142, 232, 255);
noStroke();
//hair
fill(34, 34, 34);
ellipse(width/2, height/2 - 70, 300, 150);
//face
fill(255, 183, 202);
ellipse(width/2, height/2, faceWidth, faceHeight);
//brows
fill(90, 67, 49);
var browLX = width/2 - faceWidth * 0.25;
var browRX = width/2 + faceWidth * 0.25;
ellipse(browLX, height/2 - faceWidth * 0.2, 40, 10); //left brow
ellipse(browRX, height/2 - faceWidth * 0.2, 40, 10); //right brow
//eye
fill(45, 44, 44)
var eyeLX = width/2 - faceWidth * 0.25;
var eyeRX = width/2 + faceWidth * 0.25;
ellipse(eyeLX, height/2, eyeSize, eyeSize); //left eye
ellipse(eyeRX, height/2, eyeSize, eyeSize); //right eye
//nose
fill(noseColorR, noseColorG, noseColorB);
ellipse(width/2, height/2 + faceHeight * 0.1, noseWidth, noseHeight);
//mouth
fill(189, 27, 27);
var mouthY = height/2 + faceHeight * 0.35;
ellipse(width/2, mouthY, mouthSize, mouthSize);
}
function mousePressed(){
faceWidth = random(100, 250);
faceHeight = random(110, 210);
eyeSize = random(5, 25);
noseWidth = random(10, 35);
noseHeight = random(10, 40);
noseColorR = random(0, 255);
noseColorG = random(0, 255);
noseColorB = random(0, 255);
mouthSize = random(5, 20);
}
I enjoyed this project a lot as I did not expect a lot of the faces that the codes generated. Each of the generative face is hilarious to look at. I also really appreciate how variables make the process of writing the codes so much more convenient as I just have to change one specific part to apply changes to multiple parts whenever I change my mind on something.