cchau1 – Project02 – Variable Faces

sketch


var eyeSize = 35;
var whiteSize = 15;
var faceWidth = 200;
var faceHeight = 200;
var r, g, b
var noseX = 20
var noseY = 10
var whiteHeight = 100
var whiteWidth = 35
var pinkHeight = 120
var pinkWidth = 40
var bodyW = 200
var bodyH = 250

function setup() {
    createCanvas(480,640);
    angleMode(CENTER)
    smooth()
    r = random(255);
    g = random(255);
    b = random(255);
}

function draw() {
    noStroke();
    background(165,216,255);

//bunny ears
    noStroke()
    ellipseMode(RADIUS);
    fill(250,249,250);
    ellipse(290,180,whiteWidth,whiteHeight);

    ellipseMode(CENTER);
    fill(255,225,242);
    ellipse(290,180,pinkWidth,pinkHeight);

    ellipseMode(RADIUS);
    fill(250,249,250);
    ellipse(180,180,whiteWidth,whiteHeight);

    ellipseMode(CENTER);
    fill(255,225,242);
    ellipse(180,180,pinkWidth,pinkHeight);

//head
    fill(250,249,250);
    ellipse(width / 2, height / 2, faceWidth, faceHeight);
    var eyeLX = width / 2.5 - faceWidth * 0.25;
    var eyeRX = width / 2.5 + faceWidth * 0.25;

    fill(r,g,b); //applied r,g,b random color variables to eyes
    ellipse(eyeLX, height / 2, eyeSize, eyeSize);
    ellipse(eyeRX, height / 2, eyeSize, eyeSize);

    fill(255); //white eye shine
    ellipse(eyeLX-9, height / 2 -10, eyeSize/1.5, eyeSize/1.5);
    ellipse(eyeRX-9, height / 2 -10, eyeSize/1.5, eyeSize/1.5);

    fill(255,186,223); //nose
    ellipse((width/2)-50, height/2,noseX,noseY);

//body
    fill(250,249,250);
    ellipse(width/2,height-100,bodyW,bodyH);

//flower
    translate(300,265);
    noStroke()
   for (var i = 0; i < 10; i ++) {
     fill(r,g,b);
     ellipse(0, 10, 20, 60);
     rotate(PI/5)
}

}

function mousePressed() {
    var d = dist(mouseX, mouseY, 20,60);
    if (d < 500) {
      r = random(255);
      g = random(255);
      b = random(255);
    }
    faceWidth = random(170, 250);
    faceHeight = random(15, 250);
    eyeSize = random(20,60);
    whiteHeight = random(80,140);
    whiteWidth = random(20,50);
    pinkHeight = random(90,150);
    pinkWidth = random(20,40);
    bodyW = random(200,250);
    bodyH = random(250,300);

  }

I initially planned to have only the face, eyes, and ear length to change but decided to also add a random color-changing function which was applied to the eyes and additional flower function. As I was deciding the range for the random width/height for the head, I thought to myself that in nature, there are many beautiful mathematical proportions that have allowed species to thrive but in our imagination and in cartoons, these proportions can be as hilarious or wacky as we desire!

Leave a Reply