sketch
/*
* Rachel Griswold
* rgriswol@andrew.cmu.edu
* Section B
* Project 02
*
*/
var faceWidth = 300;
var faceHeight = 300;
var eyebrowWidth = 50;
var eyebrowHeight = 10;
var eyeSize = 50;
var irisSize = 20;
var pupilSize = 10;
var noseBaseHeight = 75;
var noseBaseWidth = 30;
var noseTipHeight = 20;
var noseTipWidth = 30;
var noseTipArc1 = 3.14;
var noseTipArc2 = 6.28;
var mouthWidth = 20;
var mouthHeight = 20;
var mouthArc1 = 3.14;
var mouthArc2 = 0;
var irisColorR = 2;
var irisColorG = 174;
var irisColorB = 227;
function setup() {
createCanvas(640, 480);
}
function draw() {
var eyeL = width/2 - faceWidth * 0.25
var eyeR = width/2 + faceWidth * 0.25
var eyeL2 = height/2 - faceHeight * 0.17
var eyeR2 = height/2 - faceHeight * 0.17
background(26, 26, 26);
fill(223, 157, 151)
ellipse(width/2, height/2, faceWidth, faceHeight) // face
fill(0)
ellipse(eyeL, eyeL2, eyebrowWidth, eyebrowHeight) // eyebrow L
ellipse(eyeR, eyeR2, eyebrowWidth, eyebrowHeight) // eyebrow R
fill(255)
ellipse(eyeL, height/2, eyeSize, eyeSize) // eye L
ellipse(eyeR, height/2, eyeSize, eyeSize) // eye R
fill(irisColorR, irisColorG, irisColorB)
ellipse(eyeL, height/2, irisSize, irisSize) // iris L
ellipse(eyeR, height/2, irisSize, irisSize) // iris R
fill(0)
ellipse(eyeL, height/2, pupilSize, pupilSize) // pupil L
ellipse(eyeR, height/2, pupilSize, pupilSize) // pupil R
fill(223, 157, 151)
arc(width/2, height/1.9, noseBaseWidth, noseBaseHeight, 3.14, 0) // nose base
arc(width/2, height/1.75, noseTipWidth, noseTipHeight, noseTipArc1, noseTipArc2) // nose tip
fill(109, 27, 30)
arc(width/2, height/1.45, mouthWidth, mouthHeight, mouthArc1, mouthArc2) // mouth
}
function mousePressed() {
// when mouse is pressed, variables are randomly reassigned
faceWidth = random(200, 400);
faceHeight = random (200, 400);
eyebrowWidth = random(45, 75);
eyebrowHeight = random(5, 25);
eyeSize = random(30, 70);
irisSize = random(15, 25);
pupilSize = random(5, 15);
noseBaseWidth = random(20, 40);
noseBaseHeight = random(50, 100);
noseTipWidth = random(30, 60);
noseTipHeight = random(10, 60);
noseTipArc1 = random(0, 6.28);
noseTipArc2 = random(0, 6.28);
mouthWidth = random(10, 60);
mouthHeight = random(10, 40);
mouthArc1 = random(0, 6.28);
mouthArc2 = random(0, 3.14);
irisColorR = random(0, 255);
irisColorG = random(0, 255);
irisColorB = random(0, 255);
}
I wasn’t a fan of my original face from project 01, so I decided to create a new base-face from scratch. I wanted to make the face vary a lot, but as a result sometimes the randomly generated face looks pretty stupid. I wasn’t quite sure how to balance “lots of variability” with “not looking ridiculous” but I tried my best.