sketch_bpdohert_02
// Bridget Doherty
// Section C
var eyeSize = 20;
var faceWidth = 200;
var faceHeight = 300;
var noseWidth = 20
var on = true;
var color1 = 50;
var color2 = 50;
var color3 = 50;
function setup() {
createCanvas(640, 480);
angleMode(DEGREES);
}
function draw() {
let backgroundColor = color(color3, color2, color1);
background(backgroundColor);
let eyeColor = (color('#7d754f'));
let skinColor = (color(255, 220, 177));
let hairColor = (color('#80643d'));
var centerX = width / 2;
var centerY = height / 2;
//neck
fill(skinColor);
rect(centerX-(faceWidth/3), centerY+30, faceWidth/1.5, 200);
// main face
ellipse(centerX, centerY, faceWidth, faceHeight);
// nose
triangle(centerX, centerY+40, centerX, centerY, centerX+noseWidth, centerY+40);
//shirt
let shirtColor = color(color1, color2, color3)
fill(shirtColor);
rect(centerX-(faceWidth/2), centerY+170, faceWidth, 70)
let sleeveColor = color(color1-50, color2-50, color3-50)
fill(sleeveColor);
triangle(centerX-(faceWidth/2), centerY+170, centerX-(faceWidth/2)-30, 480, centerX-(faceWidth/2), 480);
triangle(centerX+(faceWidth/2), centerY+170, centerX+(faceWidth/2)+30, 480, centerX+(faceWidth/2), 480)
// eyes
var eyeLX = width / 2 - faceWidth * 0.25;
var eyeRX = width / 2 + faceWidth * 0.25;
fill('white'); // left eye
ellipse(eyeLX, centerY, eyeSize+20, eyeSize);
fill(eyeColor);
ellipse(eyeLX, centerY, eyeSize, eyeSize);
fill('black')
ellipse(eyeLX, centerY, eyeSize/2, eyeSize/2);
fill('white'); // right eye
ellipse(eyeRX, centerY, eyeSize+20, eyeSize);
fill(eyeColor);
ellipse(eyeRX, centerY, eyeSize, eyeSize);
fill('black')
ellipse(eyeRX, centerY, eyeSize/2, eyeSize/2);
// bowl cut hair
var hairY = (height / 2) - faceHeight/8
fill(hairColor);
arc(centerX, hairY, faceWidth, faceHeight, 180, 0);
// happy or sad mouth
var mouthY = (height / 2) + faceHeight/3.5
stroke(10);
noFill();
if (on == true) {
arc(centerX, mouthY, 80, 60, 0, 180);
} else if (on == false) {
arc(centerX, mouthY, 80, 60, 180, 0);
}
}
function mousePressed() {
faceWidth = random(150, 300);
faceHeight = random(150, 350);
eyeSize = random(10, 30);
noseWidth = random(-40, 40);
if (on == true) {
on = false;
} else {
on = true; }
getRandomColor();
}
function getRandomColor(){
// function generates a random number for color variables
color1 = random(40, 255);
color2 = random(40, 255);
color3 = random(40, 255);
}