Jenna Kim (Jeeyoon Kim)- Project 2- Variable Faces

jennakim2

/* Jenna Kim (Jeeyoon Kim)
Section E
jeeyoonk@andrew.cmu.edu
Project 2
*/

// variability
var faceX = 318;
var faceY = 257;
var faceWidth = 250;
var faceHeight = 200;

var faceColorR = 255;
var faceColorG = 177;
var faceColorB = 162;

var eyeX = 279;
var eyeY = 240;
var eyeColorR = 255;
var eyeColorG = 163;
var eyeColorB = 46;
var eyeWidth = 25;

var earX = 195;
var earY = 253;
var earWidth = 50;
var earHeight = 50;

var noseX1 = 322;
var noseY1 = 244;
var noseX2 = 302;
var noseY2 = 272;
var noseX3 = 340;
var noseY3 = 272;

var musX = 300;
var musY = 280;
var musWidth = 40;
var musHeight = 10;

var hatX = 318;
var hatY = 158;
var hatcircleX = 320;
var hatCircleY = 140;

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

function draw() {
    background(faceWidth, 230, faceHeight);  
    
    //face
    noStroke();
    fill(faceColorR, faceColorG, faceColorB);
    ellipse(faceX, faceY, faceWidth, faceHeight);

    //left eye
    noStroke();
    fill(eyeColorR, eyeColorG, eyeColorB);
    ellipse(eyeX, eyeY, eyeWidth, eyeWidth);

    //right eye
    noStroke();
    fill(eyeColorR, eyeColorG, eyeColorB);
    ellipse(eyeX + 80, eyeY, eyeWidth, eyeWidth);

    //left ear
    noStroke();
    fill(faceColorR, faceColorG, faceColorB);
    ellipse(earX, earY, earWidth, earHeight);

    //right ear
    noStroke();
    fill(faceColorR, faceColorG, faceColorB);
    ellipse(earX * 2.3, earY, earWidth, earHeight);

    //nose
    noStroke();
    fill(200);
    triangle(noseX1, noseY1, noseX2, noseY2, noseX3, noseY3);

    //mustache
    noStroke();
    fill(0);
    rect(musX, musY, musWidth, musHeight);

    //hat
    noStroke();
    fill(0);
    ellipse(hatX, hatY, faceWidth * 1/2, faceHeight * 1/7);
    noStroke();
    fill(0);
    ellipse(hatcircleX, hatCircleY, earX * 0.1, earY * 0.1);
}

function mousePressed() {
    //random eye color
    eyeColorR = random(0, 255);
    eyeColorG = random(0, 255);
    eyeColorB = random(0, 255);

    // random eye size
    eyeWidth = random(10, 40);

    //random ear size
    earWidth = random(45, 75);
    earHeight = random(45, 75);

}

It was fun to combine what we learned last week and this week to create a
face. “function mousePressed() {}” will definitely be an important tool
for my future design projects.

Leave a Reply