Yoo Jin Shin-Project-02-Variable-Face

Project-02

// Yoo Jin Shin
// Section B
// yoojins@andrew.cmu.edu
// Project-02-Variable-Face

var eyeSize = 50;

// top pupil
var pupilSizeL = 5;
var pupilSizeR = 6;
var pupilLeftX = 150;
var pupilLeftY = 154;
var pupilRightX = 220;
var pupilRightY = 154;

// bottom pupil
var pupilSize2L = 10;
var pupilSize2R = 12;
var pupilLeftX2 = 130;
var pupilLeftY2 = 164;
var pupilRightX2 = 210;
var pupilRightY2 = 166;

var faceWidth = 270;
var faceHeight = 200;
var mouthStart = 30;
var mouthStop = 122;

var backgroundR = 3;
var backgroundG = 117;
var backgroundB = 0;

var faceR = 244;
var faceG = 240;
var faceB = 132;
 
function setup() {
    createCanvas(640, 480);
}
 
function draw() {
    background(backgroundR, backgroundG, backgroundB);
    noStroke();

    // face
    fill(faceR, faceG, faceB);
    ellipse(180, 180, faceWidth, faceHeight);

    // left eye
    fill(0);
    ellipse(140, 160, eyeSize, eyeSize);

    // left pupils
    fill(255);
    ellipse(pupilLeftX, pupilLeftY, pupilSizeL, pupilSizeL);
    ellipse(pupilLeftX2, pupilLeftY2, pupilSize2L, pupilSize2L);

    // left eyebrows
    fill(backgroundR, backgroundG, backgroundB);
    rect(125, 123, 25, 7, 3);

    // right eyes
    fill(0);
    ellipse(220, 160, eyeSize, eyeSize);

    // right pupils
    fill(255);
    ellipse(pupilRightX, pupilRightY, pupilSizeR, pupilSizeR);
    ellipse(pupilRightX2, pupilRightY2, pupilSize2R, pupilSize2R);

    // right eyebrows
    fill(backgroundR, backgroundG, backgroundB);
    rect(210, 123, 25, 7, 3);

    // mouth
    fill(backgroundR, backgroundG, backgroundB);
    arc(180, 180, 20, 40, mouthStart, mouthStop);
}
 
function mousePressed() {
    eyeSize = random(37, 55);
    pupilSizeL = random(3, 9);
    pupilSizeR = random(3, 9);
    pupilSize2L = random(7, 12);
    pupilSize2R = random(7,12);

    pupilLeftX = random(142, 153);
    pupilLeftY = random(150, 155);
    pupilLeftX2 = random(142, 153);
    pupilLeftY2 = random(162, 169);

    pupilRightX = random(207, 218);
    pupilRightY = random(150, 155);
    pupilRightX2 = random(207, 218);
    pupilRightY2 = random(162, 169);

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

    faceR = random(0, 255);
    faceG = random(0, 255);
    faceB = random(0, 255);

    mouthStart = random(1, 360);
    mouthStop = random(1, 360);

    backgroundR = random(0, 255);
    backgroundG = random(0, 255);
    backgroundB = random(0, 255);
}

I tried creating a googly-eye-effect using the different variables by focusing the mouse-click changes mainly on the eyes.

Leave a Reply