Alison Hoffman – Project 2

sketch-89.js

//Alison Hoffman
//Section D
//achoffma@andrew.cmu.edu
//Project 2

var head_w1 = 240; // x coordinate of the face, left
var head_w2 = 460; // x coordinate of the face, right
var top_h = 72; // top of the head
var head_h = 60; // head height y coordinate 
var jaw_w1 = 260; // x coordinate of jaw, left
var jaw_w2 = 410; // x coordinate of jaw, right
var jaw_h = 340; // y coordinate of jaw
var bottom_h = 400; // bottom y coordinates
var eye_diam = 25;
var colorR = 140;
var colorG = 30;
var colorB = 230;
var brow_stroke = 6;
var brow_arch = 130;
var lip_stroke = 8;
var bottom_lip_x = width/2
var bottom_lip_y = height/2 + 100



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

function draw() {
	background(0);
	//face shape
    stroke(255);
    strokeWeight(9);
	//top of face
	fill(0);
    beginShape();
    curveVertex(160,180); 
    curveVertex(160,180);
    curveVertex(head_w1,head_h);
    curveVertex(width/2,top_h);
    curveVertex(head_w2,head_h);
    curveVertex(480,180);
    curveVertex(480,180);
    endShape();
    //lower face
    fill(0);
	beginShape();
    curveVertex(160,180);
    curveVertex(160,180);
    curveVertex(170,240);
    curveVertex(200,280);
    curveVertex(jaw_w1,jaw_h);
    curveVertex(width/2, bottom_h);
    curveVertex(jaw_w2,jaw_h);
    curveVertex(420,280)
    curveVertex(460,240);
    curveVertex(480,180);
    curveVertex(480,180);
    endShape();

    //eyes
    stroke(255);
    strokeWeight(12);
    fill(colorR,colorG,colorB);
    //left
    ellipse(250,180,eye_diam);
    //right
    ellipse(380,180,eye_diam);
    //lids
    stroke(colorR,colorG,colorB);
    strokeWeight(brow_stroke);
    noFill();
    //left
    beginShape();
    curveVertex(210,160);
    curveVertex(210,160);
    curveVertex(240,brow_arch);
    curveVertex(280,160);
    curveVertex(280,160);
    endShape();
    //right
    beginShape();
    curveVertex(350,160);
    curveVertex(350,160);
    curveVertex(390,brow_arch);
    curveVertex(430,160);
    curveVertex(430,160);
    endShape();

    //nose
    stroke(255);
    strokeWeight(4);
    beginShape(); 
    curveVertex(width/2,height/2 - 25);
    curveVertex(width/2,height/2 - 25);
    curveVertex(width/2 + 25, height/2+20);
    curveVertex(width/2,height/2 + 30);
    curveVertex(width/2,height/2 + 30);
    endShape();

    //mouth
    stroke(colorR,colorG,colorB);
    strokeWeight(lip_stroke);
    fill(255);
    beginShape();
    curveVertex(260,height/2 + 60);
    curveVertex(260,height/2 + 60);
    curveVertex(bottom_lip_x,bottom_lip_y);
    curveVertex(350, height/2 + 80);
    curveVertex(360, height/2 + 60);
    endShape(CLOSE);
}

function mousePressed() {
    head_w1 = random(180,240); //randomize line curve width 
    head_w2 = random(400,460); //randomize line curve width
    top_h = random(60,72); // face height 
    head_h = random(top_h,71); // randomize line curve height
    jaw_w1 = random(205,260);
    jaw_w2 = random(380,415);
    bottom_h = random(380,400);
    jaw_h = random(285,bottom_h);
    eye_diam = random(25,50);
    brow_arch = random(115,170);
    brow_stroke = random(5,18);
    lip_stroke = random(9,22);
    bottom_lip_x = random(265,385);
    colorR = random(50,230);
    colorG = random(30,240);
    colorB = random(50,255);
    bottom_lip_y = random(height/2+80,height/2+140); 

}

Leave a Reply