Caroline Song – Project 02 – Variable Face

sketch

/*  Caroline Song
    Section E
    chsong@andrew.cmu.edu
    Assignment-02 */


var eyeSize = 25
var faceWidth = 50
var faceHeight = 50
var pupilSize = 20
var noseSize = 50
var mouth = 30
var bodyHeight = 250
var bodyWidth = 250

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

function draw(){
    background(134, 227, 219);

    //face shape
    noStroke(0); 
    fill(254, 217, 255);
    ellipse(width/2, height/2, faceWidth*4, faceHeight*5);

    //eyes
    fill(250);
    var eyeLX = width/2 - faceWidth*0.75;
    var eyeRX = width/2 + faceWidth*0.75;
    ellipse(eyeLX, height/2, eyeSize*3, eyeSize*3);
    ellipse(eyeRX, height/2, eyeSize*3, eyeSize*3);

    //pupils
    fill(0);
    var pupilLX = width/2 - faceWidth*0.75;
    var pupilRX = width/2 + faceWidth*0.75;
    ellipse(pupilLX, height/2, pupilSize, pupilSize);
    ellipse(pupilRX, height/2, pupilSize, pupilSize);

    //nose
    fill(214, 0, 0);
    ellipse(width/2, height/2 + faceHeight*0.65, noseSize, noseSize);

    //mouth
    fill(245, 135, 170);
    arc(width/2, height/2 + faceHeight*1.5, mouth*2, mouth, 0, PI);

    //body
    fill(255, 243, 168);
    var faceH = faceHeight*5
    ellipse(width/2, height/2 + faceH/2 + bodyHeight/2, bodyWidth, bodyHeight);
}

    function mousePressed() {
    eyeSize = random(25, 50);
    faceWidth = random(50, 75);
    faceHeight = random(50, 75);
    mouth = random(60, 85);
    bodyHeight = random(250, 400);
    bodyWidth = random(250, 400);
}

This project was interesting in terms of using variables and math to find the coordinates to my shapes, as opposed to using Illustrator and/or Photoshop to do it for me. At first, I found this project to be challenging, but as I kept adding more objects to the face, I started to understand and familiarize myself with the process of creating this variable face.

Leave a Reply