John Henley; 15-104 section D
//John Henley; 15-104 section D
var headWidth = 150; //head variables
var headHeight = 160;
var headRound = 50;
var headColorRed = 141;
var headColorGreen = 227;
var headColorBlue = 204;
var hairHeight = 120 //hair variables
var hairColorRed = 12;
var hairColorGreen = 8;
var hairColorBlue = 10;
var eyeWidth = 20; //eye variables
var eyeGap = 25;
var eyeHeight = headHeight / 5;
var mouthWidth = 50; //mouth variables
var mouthHeight = 40;
var backgroundValue = 150; //canvas variables
function setup() {
createCanvas(500, 500);
}
function draw() { //draw initial face
background(backgroundValue);
rectMode(CENTER);
noStroke();
fill(hairColorRed, hairColorGreen, hairColorBlue);
rect(width / 2, height / 2 - headHeight / 2, headWidth + 30, hairHeight, 20, 20, 10, 10); //hair
fill(headColorRed, headColorGreen, headColorBlue);
rect(width / 2, height / 2, headWidth, headHeight, headRound / 2, headRound / 2, headRound, headRound); //head
fill(0);
ellipse(width / 2 - eyeGap, height / 2 - eyeHeight, eyeWidth); //left eye
ellipse(width / 2 + eyeGap, height / 2 - eyeHeight, eyeWidth); // right eye
fill(255);
ellipse(width / 2 - eyeGap, height / 2 - eyeHeight, eyeWidth / 1.5); //left highlight
ellipse(width / 2 + eyeGap, height / 2 - eyeHeight, eyeWidth / 1.5); // right highlight
stroke(0);
strokeWeight(5);
noFill();
arc(width / 2, height / 2 + eyeGap - 20, mouthWidth, mouthHeight, TWO_PI, PI); //mouth
}
function mousePressed() {
//randomly adjust variables
headWidth = random(120, 200);
headHeight = random(140, 230);
headColorRed = random(128, 255);
headColorGreen = random(128, 255);
headColorBlue = random(128, 255);
hairHeight = random(40, 160);
hairColorRed = random(0, 127);
hairColorGreen = random(0, 127);
hairColorBlue = random(0, 127);
eyeWidth = random(10, 35);
eyeGap = random(18, 40);
mouthWidth = random(40, 60);
mouthHeight = random(20, 50);
backgroundValue = random(10, 245);
}