PROJECT-02 (variable faces)

SEAN-02
// SEAN CHEN
// 15-104 A

function setup() {
    smooth();
    createCanvas(600, 600);
}

function mouseClicked() {
    noStroke();
    background(232, 232, 228);

    var cntr = width / 2;
    var facex = random(width/4, width/2);
    var facey = random(width/4, width/2);

    // FACE BASE
    fill(255, 219, 88);
    var x = 10
    var ushift = random(-x, x);
    var rshift = random(-x, x);
    var dshift = random(-x, x);
    var lshift = random(-x, x);
    beginShape();
    curveVertex(cntr+ushift, cntr-facey/2+rshift);
    curveVertex(cntr+facex/2+ushift, cntr-facey/2+rshift);
    curveVertex(cntr+facex/2+rshift, cntr+dshift);
    curveVertex(cntr+facex/2+rshift, cntr+facey/2+dshift);
    curveVertex(cntr+dshift, cntr+facey/2+lshift);
    curveVertex(cntr-facex+dshift, cntr+facey/2+lshift);
    curveVertex(cntr-facex/2+lshift, cntr+ushift);
    curveVertex(cntr-facex/2+lshift, cntr-facey+ushift);
    endShape(CLOSE);
    
    // eye whites
    fill(255);
    var eyew = random(height/20, height/10);
    stroke(255);
    strokeWeight(eyew);
    beginShape(LINES);
    vertex(cntr-facex/4, cntr);
    vertex(cntr-facex/4, cntr-facey/4);
    vertex(cntr+facex/4, cntr);
    vertex(cntr+facex/4, cntr-facey/4);
    endShape();

    // pupils
    stroke(0);
    strokeWeight(eyew/4*3);
    var pupil = eyew/8*5;
    var lshift = random(-5, 5);
    var rshift = random(-5, 5);
    beginShape(POINTS);
    vertex(cntr-facex/4+lshift, cntr-5+2*rshift);
    vertex(cntr-facex/4+lshift, cntr-5-pupil+2*rshift);
    vertex(cntr+facex/4+rshift, cntr-5+2*lshift);
    vertex(cntr+facex/4+rshift, cntr-5-pupil+2*lshift);
    endShape();

    // eyelids
    beginShape(POINTS);
    stroke(255, 180, 88);
    strokeWeight(eyew);
    vertex(cntr-facex/4, cntr-facey/4);
    vertex(cntr+facex/4, cntr-facey/4);
    endShape();
    beginShape();
    noStroke();
    fill(255, 180, 88);
    vertex(cntr-facex/4-eyew/2, cntr-facey/4);
    vertex(cntr-facex/4+eyew/2, cntr-facey/4);
    vertex(cntr-facex/4+eyew/2, cntr-facey/4+eyew/2);
    vertex(cntr-facex/4-eyew/2, cntr-facey/4+eyew/2);
    endShape();
    beginShape();
    vertex(cntr+facex/4-eyew/2, cntr-facey/4);
    vertex(cntr+facex/4+eyew/2, cntr-facey/4);
    vertex(cntr+facex/4+eyew/2, cntr-facey/4+eyew/2);
    vertex(cntr+facex/4-eyew/2, cntr-facey/4+eyew/2);
    endShape();

    // eyebrows
    var broww = eyew/2;
    var browshift = random(-10, 10);
    stroke(0);
    strokeWeight(20);
    beginShape();
    curveVertex(cntr-facex/4-broww, cntr-facey/4-eyew/2+browshift);
    curveVertex(cntr-facex/4-broww, cntr-facey/4-eyew/2+browshift);
    curveVertex(cntr-facex/4, cntr-facey/4-eyew/2);
    curveVertex(cntr-facex/4+broww, cntr-facey/4-eyew/2+browshift/4);
    curveVertex(cntr-facex/4+broww, cntr-facey/4-eyew/2+browshift/4);
    endShape();
    beginShape();
    curveVertex(cntr+facex/4-broww, cntr-facey/4-eyew/2+browshift/4);
    curveVertex(cntr+facex/4-broww, cntr-facey/4-eyew/2+browshift/4);
    curveVertex(cntr+facex/4, cntr-facey/4-eyew/2);
    curveVertex(cntr+facex/4+broww, cntr-facey/4-eyew/2+browshift);
    curveVertex(cntr+facex/4+broww, cntr-facey/4-eyew/2+browshift);
    endShape();

    //lips
    var mouthw = facex/4*3
    var mouthshift = random(-100, 100);
    stroke(255, 38, 38);
    strokeWeight(random(30, 50));
    beginShape();
    curveVertex(cntr-mouthw/2, cntr+facey/4+mouthshift);
    curveVertex(cntr-mouthw/2, cntr+facey/4);
    curveVertex(cntr+mouthw/2, cntr+facey/4);
    curveVertex(cntr+mouthw/2, cntr+facey/4+mouthshift);
    endShape();
    stroke(0);
    strokeWeight(5);
    noFill();
    beginShape();
    curveVertex(cntr-mouthw/2, cntr+facey/4+mouthshift);
    curveVertex(cntr-mouthw/2, cntr+facey/4);
    curveVertex(cntr+mouthw/2, cntr+facey/4);
    curveVertex(cntr+mouthw/2, cntr+facey/4+mouthshift);
    endShape();

}

Leave a Reply