Project 02: Variable Face

This one was a struggle, not gonna lie, so I chose to make this one simpler: cross-eyed monochrome faces.

// Kailani Small
// Section A

// cross-eyed monochrome faces
var eyeSize;
var pupilSize;
var faceWidth;
var faceHeight;
var r;
var g;
var b;

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

function draw() {
background(225);
// face shape
ellipse(width / 2, height / 2, faceWidth, faceHeight);

// eyes
var lefteye = width / 2 - faceWidth * 0.25;
var righteye = width / 2 + faceWidth * 0.25;
ellipse(lefteye, height / 2, eyeSize, eyeSize);
ellipse(righteye, height / 2, eyeSize, eyeSize);
var leftpupil = width / 2 - faceWidth * 0.2;
var rightpupil = width / 2 + faceWidth * 0.2;
ellipse(leftpupil, height / 2, pupilSize, pupilSize);
ellipse(rightpupil, height / 2, pupilSize, pupilSize);

// mouth
ellipse(width / 2, height * .6, faceWidth * 0.25, faceHeight * 0.25);

}

function mousePressed() {
// when the user clicks, these variables are reassigned
// to random values within specified ranges
faceWidth = random(75, 150);
faceHeight = random(100, 200);
eyeSize = random(10, 30);
faceColor = fill(random(140, 255));
pupilSize = random(5, 8);
}

Leave a Reply