Kyle Lee Variable Face

The biggest challenge for me was properly sorting the local variables, global variables, and mouse pressed function. I felt good about the lines of code that I wrote, but it took me a long time of moving the lines to different locations in the code to finally get the result I wanted.

kdlee-project-02

var faceWidth = 100;
var faceHeight = 150;
var mouthWidth = 50;
var mouthHeight = 20;
var eyeSize = 20;
var eyeLidWidth = 10;
var eyeLidHeight = 2;
var irisColor = '#A46861';
var colors = ['#A46861', '#8CAEDC', '#A9BD8C'];

function setup() {
    createCanvas(480, 640);
}

function draw() {
    background('#5D8FA4');
    noStroke();

//HEAD
    fill('#F2C4A2');//SKIN TONE
    ellipse(width / 2, height / 2, faceWidth,  faceHeight);//HEAD
//MOUTH
    fill(0);//BLACK
    ellipse(width / 2, height / 2 + faceHeight / 4, mouthWidth, mouthHeight);//MOUTH

//EYE WHITES
    var eyeLX = width / 2 - faceWidth * 0.25;
    var eyeRX = width / 2 + faceWidth * 0.25;
    fill(250);//WHITE
    ellipse(eyeLX, height / 2, eyeSize, eyeSize);//LEFT EYE
    ellipse(eyeRX, height / 2, eyeSize, eyeSize);//RIGHT EYE
//EYE IRIS
    var eyeIris = 9;
    fill(irisColor);//IRIS COLOR
    ellipse(eyeLX, height / 2, eyeIris, eyeIris);//LEFT IRIS
    ellipse(eyeRX, height / 2, eyeIris, eyeIris);//RIGHT IRIS
//EYE PUPIL
    var eyeP = 5;
    fill(0);//BLACK
    ellipse(eyeLX, height / 2, eyeP, eyeP);//LEFT PUPIL
    ellipse(eyeRX, height / 2, eyeP, eyeP);//RIGHT PUPIL
//EYELIDS
    var eyeLidY = height / 2 - eyeSize
    noFill();
    stroke(1);
    strokeWeight(2);
    arc(eyeLX, eyeLidY, eyeLidWidth, eyeLidHeight, PI, 0);//LEFT EYELID
    arc(eyeRX, eyeLidY, eyeLidWidth, eyeLidHeight, PI, 0);//RIGHT EYELID
}

function mousePressed() {
    faceWidth = random(75, 150);
    faceHeight = random(100, 200);
    mouthWidth = random(50, 30);
    mouthHeight = random(30, 5);
    eyeSize = random(10, 30);
    eyeP = random (5, eyeSize - 10);// Pupil
    eyeIris = (eyeSize - eyeP) / 2; //Iris size
    eyeLidWidth = random(12, 7);
    eyeLidHeight = random(7, 0);
    irisColor = random(colors);
}

Leave a Reply