thlai-Project-02-Variable-Face


thlai-project02

// Tiffany Lai
// 15-104 Section A
// thlai@andrew.cmu.edu
// Project-O2

var eyeSize = 0;
var mouth1 = 60;
var mouth2 = 120;
var skinR = 210;
var skinG = 210;
var skinB = 210;
var eyebrows = 275;
var eyebrowStroke = 10;
var snout = 115;
var jaw1 = 240;
var jaw2 = 200;

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

function draw() {
    background(255, 250, 230);
    noStroke();

    fill(skinR, skinG, skinB);
    beginShape(); // left ear
        curveVertex(220, 260);
        curveVertex(220, 260);
        curveVertex(180, 100);
        curveVertex(120, 100);
        curveVertex(170, 280);
        curveVertex(170, 280);
    endShape(); 

    beginShape(); // right ear
        curveVertex(250, 280);
        curveVertex(250, 280);
        curveVertex(300, 100);
        curveVertex(350, 100);
        curveVertex(310, 280);
        curveVertex(320, 280);
    endShape();

    ellipse(width/2, height/2, 200, 200); // head top
    ellipse(width/2, height/2+40, jaw1, jaw2); // head bottom

    fill(255);
    ellipse(width/2, height/2+60, snout, snout); // snout

    fill(70);
    ellipse(width/2-50, height/2, eyeSize+20, eyeSize+30); // left eye
    ellipse(width/2+50, height/2, eyeSize+20, eyeSize+30); // right eye

    push();
    stroke(skinR-20, skinG-20, skinB-20);
    strokeWeight(eyebrowStroke);
    line(178, eyebrows, 198, eyebrows-5); // left eyebrow
    pop();

    push();
    stroke(skinR-20, skinG-20, skinB-20);
    strokeWeight(eyebrowStroke);
    line(300, eyebrows, 280, eyebrows-5); // right eyebrow
    pop();

    fill(250, 225, 235);
    triangle(width/2-10, height/2+30, width/2+10, height/2+30, width/2, height/2+50); // nose

    fill(255, 100, 140);
    arc(width/2, height/2+60, 80, 80, mouth1, mouth2); // mouth
}

function mousePressed() {
    eyeSize = random(-10, 20);
    mouth1 = random(-10, 80);
    mouth2 = random(100, 190);
    skinR = random(200, 240);
    skinG = random(200, 240);
    skinB = random(200, 240);
    eyebrows = random(240, 300);
    eyebrowStroke = random(5, 20);
    snout = random(95, 150);
    jaw1 = random(220, 250);
    jaw2 = random(175, 210);
}

 

Leave a Reply