Shannon Case- Project 02- Variable Face

scase-project-02

// Shannon Case
// Section D
// scase@andrew.cmu.edu
// Project 02

//set variables
var eyeSize = 20;
var faceWidth = 100;
var faceHeight = 150;
var mouthX = 15;
var mouthY = 15;

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

function draw() {
    background(255,8,127); // makes the background hot pink

    //faceshape
    fill(238,90,200); //makes the face purple
    ellipse(width / 2, height / 2, faceWidth,  faceHeight); //creates the face
    
    //sets eye variables
    var eyeLX = width / 2 - faceWidth * 0.25;
    var eyeRX = width / 2 + faceWidth * 0.25;
    
    //eyes
    ellipseMode(RADIUS); 
    fill(255);  // Set fill to white
    ellipse(eyeLX, height / 2, eyeSize, eyeSize); 
    ellipseMode(CENTER); 
    fill(127,255,12); //makes pupils lime green
    ellipse(eyeLX, height / 2, eyeSize, eyeSize);

    ellipseMode(RADIUS);  
    fill(255);  // Set fill to white
    ellipse(eyeRX, height / 2, eyeSize, eyeSize); 
    ellipseMode(CENTER); 
    fill(127,255,12); // lime green color 
    ellipse(eyeRX, height / 2, eyeSize, eyeSize);

    //mouth
    fill(151,255,255); //fill the mouth blue
    ellipse((width/2)+10,(height/2)+30, mouthX, mouthY); //adds a mouth

    //eyebrows
    fill(255);
    rect(eyeLX-15, eyeLX-95, 30, 5); // left eyebrow
    rect(eyeRX-15, eyeRX-150, 30, 5); //right eyebrow

}

function mousePressed() {
    // when the user clicks, these variables are reassigned
    // to random values within specified ranges.
    faceWidth = random(80, 150);
    faceHeight = random(100, 200);
    eyeSize = random(10, 25);
    mouthX = random(1,20);
    mouthY = random(1,20);
}

For this project I started with the simple template given. I wanted to create a face that showed a surprised emotion, as it is surprising when the face changes with each click. I chose to show this with wide open eyes, an open mouth, and raised eyebrows, one slightly above the other. I chose to give the background and face fun colors to make a more interesting shape. The hardest part of this assignment for me was keeping the shapes on the face, as sometimes they tended to fly out into random places.

Leave a Reply