Chelsea Fan-Project-02

VariableFaces

/* Chelsea Fan
Section 1B
chelseaf@andrew.cmu.edu
Project-02
*/

var eyeSize = 20;
var faceWidth = 100;
var faceHeight = 150;
var earWidth = 20;
var earHeight = 100;
var bodyWidth = 100;

 
function setup() {
    createCanvas(640, 480);
    noStroke(0);
}
 
function draw() {
    background(205, 92, 92);
    // Head
    fill(250, 250, 250);
    ellipse(width / 2, height / 2, faceWidth,  faceHeight);
    //body
    fill(250, 250 , 250);
    var bodyHeight = 200;
    ellipse(width/2, height/2+150, bodyWidth, bodyHeight);
    //Ear
    ellipse(width/2 + 25, height/2-100, earWidth, earHeight);
    ellipse(width/2 - 25, height/2-100, earWidth, earHeight);
    // Eyes
    fill(173, 216, 230);
    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);
    //nose
    fill(255, 182, 193);
    triangle(310, 250, 330, 250, 320, 260);
}
 
function mousePressed() {
    // when mouse is pressed, variability occurs in eyesize, earsize, and headsize
    faceWidth = random(75, 150);
    faceHeight = random(100, 200);
    eyeSize = random(10, 30);
    earHeight = random(100, 200);
    bodyWidth = random(100, 300);

    if (faceWidth>=120||faceHeight>=170) {
    	eyeSize = random(20, 30);
    }  else {
    	eyeSize = random(10, 20);
    }
    if (faceWidth>=120||faceHeight>=170) {
    	earHeight = random(150, 250);
    }  else {
    	earHeight = random(100, 175);
    }

}

I spent quite a bit of time deciding what character to draw and I finally decided on a bunny. I enjoyed playing around with the random sizes for the bunny’s ears, eyes, and head shape.

Leave a Reply