selinal-Project-02

sketch

//Selina Lee
//Section C
//selinal@andrew.cmu.edu
//Project 02

var nosesi = 75 //size of nose
var noseco = 40 //R value for nose
var noseco2 = 120 //G value for nose
var glintx = 210 //x-location for glint
var glinty = 190 //y for glint

function setup() {
    createCanvas(640, 480);
    background(200);

}

function draw() {
    //create facial surface
    stroke(0);
    strokeWeight(3);
    fill(230, 80, 160);
    ellipse(320, 240, 440, 330);

    //creating parameters for the smile
    var lipx = constrain(mouseX, 130, 220); //defining the interactive limits of the mouse location
    var lipy = constrain(mouseY, 250, 320); 

    //creating the mouth
    noFill();
    stroke(0);
    strokeWeight(1);
    beginShape();
    curveVertex(lipx, lipy);
    curveVertex(lipx, lipy);
    curveVertex(width/2 - lipx/2, lipy + 50);
    curveVertex(width/2 + lipx/2, lipy + 50);
    curveVertex(width - lipx, lipy);
    curveVertex(width - lipx, lipy);
    endShape();

    //creating the nose
    fill(noseco, noseco2, 130);
    stroke(0);
    strokeWeight(1);
    ellipse(320 , 240, nosesi, nosesi/2);

    //defining eyebrow raise and parameters
    var eyebroy = constrain(mouseY, 120, 170);

    stroke(150, 100, 100);
    strokeWeight(10);
    line(160, 180, 250, eyebroy); //left brow
    line(480, 180, 390, eyebroy); //right brow

    //creating blinking eyes
    var pupil = random(20, 35); 

    stroke(0);
    fill(0);
    ellipse(200, 190, pupil, pupil); //left eye
    ellipse(440, 190, pupil, pupil); //right eye

    strokeWeight(0);
    fill(255);
    ellipse(glintx, glinty, 10, 10); //left eyeglint
    fill(255);
    ellipse(width - glintx, glinty, 10, 10); //right eyeglint
    

}
    


function mousePressed() {
    nosesi = random (20, 130); //nose width
    noseco = random (0, 250); //value of R for nose
    noseco2 = random (110, 130); //value of G for nose
    glintx = random (180, 220); //random placement of white eyeglint ellipeses on x-axis
    glinty = random (180, 200); //random placement of eyeglint on y-axis
}

Leave a Reply