Daniel Teague – Project02 – Variable Faces

Project02

var eyeSize = 30;
var faceWidth = 120;
var faceHeight = 230;
var noseHeight = 40;
var eyeHL = 4;
var eyeHR = 3;

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

function draw() {
    /*creating face structure*/
    ellipse(width / 2, height / 2, faceWidth, faceHeight);
    /*creating variables for eye location*/
    var eyeLX = width / 2 - faceWidth / 4
    var eyeLY = height / 2 + faceHeight / eyeHL
    var eyeRX = width / 2 + faceWidth / 4
    var eyeRY = height / 2 + faceHeight / eyeHR
    /*creating eyes*/
    ellipse(eyeLX, eyeLY, eyeSize, eyeSize);
    ellipse(eyeRX, eyeRY, eyeSize, eyeSize);
    /*creating nose*/
    triangle(width / 2 - noseHeight / 2, height /2, width /2 + noseHeight / 2, width / 2, height / 2 + noseHeight);
}
    
function mousePressed(){
    var eyeSize = random(20, 50);
    var faceWidth = random(100, 300);
    var faceHeight = random(200, 400);
    var noseHeight = random(30, 60);
    var eyeHL = random(3, 5);
    var eyeHR = random(3, 5);
}

This is a late turn in, but I had fun with this so I’m putting this up for others to see.

The variable creation was both harder and easier than I had originally thought (not the reason this is late). I wanted to create a mouth as well, but found that too difficult to create variables for. However, the nose felt like it turned out well.

Leave a Reply