Project-02-Variable-Face-sjahania

sketch

// Simple beginning template for variable face.
var eyeSize = 20;
var faceWidth = 175;
var faceHeight = 150;
var noseWidth = 50;
var noseHeight = 30;
var pupilX = 0;
var pupilY = 0;
var faceRedness = 190;
var noseRedness = 220;
var earSize = 50;
 
function setup() {
    createCanvas(640, 480);
}
 
function draw() {
    background(180);
    fill(255);

    //ears
    fill(noseRedness, 180, 184);
    ellipse(width / 2 - faceWidth / 3, height / 2 - faceHeight / 3, earSize, earSize)
    ellipse(width / 2 + faceWidth / 3, height / 2 - faceHeight / 3, earSize, earSize)

    //face
    fill(faceRedness, 113, 166);
    ellipse(width / 2, height / 2, faceWidth,  faceHeight);

    //eyes
    fill(255);
    var eyeLX = width / 2 - faceWidth * 0.25;
    var eyeRX = width / 2 + faceWidth * 0.25;
    ellipse(eyeLX, height / 2, eyeSize, eyeSize);
    ellipse(eyeRX, height / 2, eyeSize, eyeSize);

    //pupils
    fill(0);
    ellipse(eyeLX + pupilX, height / 2 + pupilY, eyeSize * .65, eyeSize * .65);
    ellipse(eyeRX + pupilX, height / 2 + pupilY, eyeSize * .65, eyeSize * .65);

    //nose
    fill(noseRedness, 180, 184);
    ellipse(width / 2, height / 2 + faceHeight / 4, noseWidth,noseHeight);


    //nostrils
    fill(0);
    var Lnostril = width / 2 - noseWidth / 4
    var Rnostril = width / 2 + noseWidth / 4
    ellipse(Lnostril, height / 2 + faceHeight / 4, 10, 10);
    ellipse(Rnostril, height / 2 + faceHeight / 4, 10, 10);

    //speech bubble
    fill(255);
    noStroke();
    rect(450, 75, 150, 125, 25);
    triangle(425, 250, 460, 195, 480, 195);

    //hamburger
    fill(255,201,77);
    arc(525, 125, 80, 60, PI, TWO_PI);
    fill(224,37,33);
    rect(485, 125, 80, 10, 15);
    fill(255,201,77);
    rect(485, 135, 80, 6, 15);
    fill(74,207,0);
    rect(485, 141, 80, 6, 15);
    fill(68,37,33);
    rect(485, 147, 80, 15, 15);
    fill(255,201,77);
    rect(485, 162, 80, 15, 0, 0, 15, 15);




}
 
function mousePressed() {
    // when the user clicks, these variables are reassigned
    // to random values within specified ranges. For example,
    // 'faceWidth' gets a random value between 75 and 150.
    faceWidth = random(150, 250);
    faceHeight = random(100, 200);
    eyeSize = random(10, 30);
    noseHeight = random(20,40);
    noseWidth = random(30,70);
    pupilX = random(-2,2);
    pupilY = random(-2,2);
    faceRedness = random(179,255);
    noseRedness = random(216,255);
    earSize = random(40,60);





}

This was hard because I don’t know how to draw faces. I ended up using simple circles to draw pigs, and made the eyes, nose, face color, and face size/shape change. I added a hamburger for fun.

Leave a Reply