/*Carley Johnson
Section E
cbjohnso@andrew.cmu.edu
Assignment 02A
*/
var skinColor = 250
var headH = 175
var headW = 150
var eyeColor = 226
var lipColor = 145
var lipCorner = 200
var hairLength = 220
var eyebrowH1 = 160
var eyebrowH2 = 155
function setup() {
createCanvas(640, 480);
}
function draw() {
background(182, 212, 115);
fill(112, 62, 40)
stroke(112, 62, 40)
rect(200, 90, 220, hairLength, 100, 100, 0, 0 ) //back hair
fill(255, skinColor, 180)
stroke(skinColor)
ellipse(300, 200 , headW, headH) //Head
fill(128, eyeColor, 252)
stroke(70)
ellipse (275, 175, 10, 10) //Left Eye
fill(128, eyeColor, 252)
stroke(70)
ellipse (300, 175, 10, 10) //Right Eye
fill(255, 124, lipColor)
stroke(255, 124, 145)
bezier(275, lipCorner, 280, 210, 285, 210, 300, lipCorner) //mouth
fill(215, 106, 58)
stroke(215, 106, 58)
rect (270, 90, 125, 75, 0, 50, 0, 50) //bangs
fill(112, 62, 40)
stroke(112, 62, 40)
bezier(255, eyebrowH1, 270, eyebrowH2, 280, eyebrowH2, 280, eyebrowH1) //Left eyebrow
fill(112, 62, 40)
stroke(112, 62, 40)
bezier(290, eyebrowH1, 290, eyebrowH2, 300, eyebrowH2, 320, eyebrowH1) //right eyebrow
}
function mousePressed() {
skinColor = random(190, 250)
headW = random(150, 200)
headH = random(150, 200)
eyeColor = random(190, 270)
lipColor = random(60, 160)
lipCorner = random(220, 185)
hairLength = random(200, 300)
eyebrowH1= random(170, 160)
eyebrowH2 = random(160, 145)
}
This was tough, a real learn-by-doing experience. Now I feel like I really understand variables and how to control them (like learning to add parameters to the ‘randomness’ under the mousePressed function) and am proud of this. It may not be the most complex face, but it definitely changes and the way the expression changes (done by changing the height of the corners of the mouth and eyebrows) which I really like.