JamesKatungyi-Project02-VariableFaces

jameskatungyi-project02-variablefaces

//James Katungyi
//Section A (Tuesdays 9:00)
//jkatungy@andrew.cmu.edu
//Project-02-Variable-Faces

var hairWidth = 240;
var hairHeight = 240;
var LEheight = 20;
var LEwidth = 60;
var REheight = 20;
var REwidth = 60;
var NoseWidth = 30;
var EyeBrowStartY = 305;
 
function setup() {
    createCanvas(480, 640);
    background(135);

}

function draw() {
    //hair
    fill(0);
    ellipse(width/2, 260, hairWidth, hairHeight);
    //face
    fill(175, 135, 0);
    stroke(110);
    strokeWeight(1);
    ellipse(width/2, height/2, 240, 320);
    //more hair
    fill(0);
    noStroke();
    ellipse(width/2, 200, 180, 90);
    //lashes
    stroke(0);
    strokeWeight(4);
    line(270, EyeBrowStartY, 330, 290); //Right brow
    line(210, EyeBrowStartY, 150, 290); //Left brow
    //eyes
    fill(222);
    ellipse(300, height/2, REwidth, REheight); //Right Eye
    ellipse(180, height/2, LEwidth, LEheight); //Left Eye
    fill(45);
    ellipse(300, height/2, 10); //Right pupil
    ellipse(180, height/2, 10); //Left pupil
    //nose
    stroke(240, 150, 0);
    strokeWeight(1);
    fill(200, 135, 0);
    ellipse(width/2, 350, NoseWidth, 60); //bridge
    ellipse(225, 372, 15); //right nostril
    ellipse(255, 372, 15); //left nostril
    //mouth
    stroke(0);
    strokeWeight(1);
    noFill(200, 135, 0);
    curveVertex(195, 400);
    curveVertex(210, 408);
    curveVertex(240, 415);
    curveVertex(270, 408);
    curveVertex(285, 400);
    endShape();
}
 
function mousePressed() {
    // when the user clicks, these variables are reassigned
    // to random values within specified ranges. For example,
    // 'faceWidth' gets a random value between 75 and 150.
    hairWidth = random(240, 360);
    hairHeight = random(240, 360);
    LEheight = random(10, 30);
    LEwidth = random(30, 60);
    REheight = random(10, 30);
    REwidth = random(30, 60);
    NoseWidth = random(20, 40);
    EyeBrowStartY = random(275, 305);
}

A sketch helped. The outcome was close… I had to tamper down initial ambitions.

variablefacedraft

Leave a Reply