Alec Albright – Project 02 – Variable Face

sketch

// ALec Albright
// Section B
// aalbrigh@andrew.cmu.edu
// Project 02

var hairHeight = 130;
var hairWidth = 365;
var hairRed = 230;
var foreheadH = 320;
var foreheadW = 160;
var foreheadBlue = 255;
var lowerRed = 240;
var noseBlue = 255;
var leftEyeY = 175;
var rightEyeY = 200;
var leftPupilX = 230;
var rightPupilX = 340;
var jawWeight = 30;

function setup(){
    height = 480
    width = 640
    createCanvas(width, height);
    angleMode(DEGREES);
}

function draw(){
    background("blue");
    // forehead
    fill(0, 255, foreheadBlue);
    noStroke();
    rect(140, 120, foreheadH, foreheadW);

    // lower half of face
    noStroke();
    fill(lowerRed, 0, 200);
    quad(125, 270, 475, 270, 370, 470, 250, 470);

    // mouth
    fill("black");
    arc(300, 370, 100, 40, -10, 170, PIE);

    // nose
    fill(153, 51, noseBlue);
    triangle(300, 230, 325, 320, 300, 330);

    // eyes
    fill("white");
    ellipse(240, leftEyeY, 45, 80);
    ellipse(350, rightEyeY, 60, 95);
    fill('black');
    ellipse(leftPupilX, leftEyeY + 15, 15, 30);
    ellipse(rightPupilX, rightEyeY + 20, 23, 40);

    // hair
    fill(hairRed, 130, 0);
    rect(120, 0, hairWidth, hairHeight, 160, 40, 60, 0);

    // jaw
    stroke('yellow');
    strokeWeight(jawWeight);
    line(150, 320, 250, 470);
    stroke("red");
    line(200, 445, 435, 445);
    stroke('limegreen');
    line(450, 295, 350, 505);
}

function mousePressed(){
    hairHeight = random(110, 150);
    hairWidth = random(335, 395);
    hairRed = random(0, 255);
    foreheadBlue = random(0, 255);
    foreheadH = random(300, 340);
    foreheadW = random(140, 180);
    lowerRed = random(0, 255);
    noseBlue = random(0, 255);
    leftEyeY = random(145, 205);
    rightEyeY = random(160, 240);
    leftPupilX = random(220, 260);
    rightPupilX = random(320, 360);
    jawWeight = random(10, 50);
    clear();
}

At the beginning of the process, I struggled to find what variables I would like to create, and what facial features I wanted to generate. I eventually wound up deciding that I wanted to change most structural aspects within constraints, a few color aspects, and absolutely let the pupils of the eyes cross if randomly selected to do so. Thus, I began toying with various features, dimensions, and colors until the result was a satisfying range of diversity in faces, based on my previous project.

Leave a Reply