Jinhee Lee; Project-02: Variable Faces

Biggest thing I noticed afterwards – didn’t draw any sketches. Using variables didn’t serve to just compact the code and make it easier to manipulate the visual with just a few changes, but also allowed me to make relative measurements as opposed to exact measurements for every conceivable feature.

jinheel1_project-02

//Jinhee Lee
//Section C
//jinheel1@andrew.cmu.edu
//Project-02

//beginning template for face
var eyeSize = 10;
var eyeColor = "white";
var faceWidth = 200;
var faceHeight = 300;
var faceColor = "white";
var noseColor = "white";
var smileWidth = 50;
//beginning face mostly white for a blank canvas

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

function draw() {
    background('purple');

    fill(faceColor); //changing face/skin color
    ellipse(width/2,height/2,faceWidth,faceHeight); //changing face size

    var eyeLX = width/2 - faceWidth/4; //varying eyes' position
    var eyeRX = width/2 + faceWidth/4;

    fill(255); //white color for eyeball
    ellipse(eyeLX,height/2,3*eyeSize,2*eyeSize); //drawing eyeballs
    ellipse(eyeRX,height/2,3*eyeSize,2*eyeSize);
    strokeWeight(5); //drawing iris
    stroke(eyeColor); //changing iris color
    fill(0); //making the black pupil
    ellipse(eyeLX,height/2,eyeSize,eyeSize); //varying eye size for pupil and iris
    ellipse(eyeRX,height/2,eyeSize,eyeSize);
    strokeWeight(1);
    stroke(0); 
    //above two functions reset to default

    var noseTY = height/2 - faceWidth/8; //varying nose length
    var noseBY = height/2 + faceWidth/5;

    fill(noseColor); //changing nose color
    triangle(width/2,noseTY,width/2 - faceWidth/10,noseBY,width/2 + faceWidth/10,noseBY);

    fill(135,45,45); //default color for mouth
    arc(width/2,height/2 + faceHeight/3,smileWidth,faceWidth/6,0,PI,CHORD); //draws mouth with varied width
}

function mousePressed() {

	faceWidth = random(150,300);
	faceHeight = random(200,400);

	eyeSize = random(10,20);
	eyeColor = random(["#00CED1","#20B2AA","#CD853F","#8B4513","#C0C0C0","#FF0000"]);

	faceColor = random(["#FFE4C4","#DEB887","#DAA520","#FFDAB9","#8B4513",]);

	noseColor = random(["orange","yellow","green","blue","purple"]);
    //meanwhile, in a parallel universe where people's noses are a random color from OY G. BIV
    //and Rudolph, the only red-nose is their ruler
}

Disregard those two last comments in the code.

Leave a Reply