Romi Jin – Project-02-Variable-Face-Section B

sketch

/*Romi Jin
Section B
rsjin@andrew.cmu.edu
Assignment-02-A
*/

var earWidth = 50
var earLength = 150
var earX = 150
var earY = 200

var faceWidth = 225
var faceX = 225
var faceY = 340

var eyeWidth = 35
var eyeX = 180
var eyeY = 350
var eyeColorR = 0
var eyeColorG = 0
var eyeColorB = 0

var noseWidth = 30
var noseLength = 15
var noseX = 225
var noseY = 385

var word = 0
var wordNumber = 0


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

function draw() {
    background(245,215,215);

    //left ear
    noStroke();
    fill(255);
    ellipse(earX,earY,earWidth,earLength);

    noStroke();
    fill(253, 229, 255);
    ellipse(earX,earY+25,earWidth/2,earLength/2);

    //right ear
    noStroke();
    fill(255);
    ellipse(2*earX,earY,earWidth,earLength);

    noStroke();
    fill(253, 229, 255);
    ellipse(2*earX,earY+25,earWidth/2,earLength/2);

    //face
    noStroke();
    fill(255);
    ellipse(faceX,faceY,faceWidth,faceWidth);

    //left eye
    noStroke();
    fill(eyeColorR,eyeColorG,eyeColorB);
    ellipse(eyeX,eyeY,eyeWidth,eyeWidth);

    //right eye
    noStroke();
    fill(eyeColorR,eyeColorG,eyeColorB);
    ellipse(eyeX+85,eyeY,eyeWidth,eyeWidth);

    //nose
    noStroke();
    fill(0);
    ellipse(noseX,noseY,noseWidth,noseLength);

    //text
    var word = int(wordNumber);
    if (word == 1) {
        noStroke();
        textSize(20);
        fill(0);
        text("bunny", 205, 500);


    } else if (word == 2){
        noStroke();
        textSize(20);
        fill(0);
        text("rabbit", 205, 500);

    } else if (word == 3){
        noStroke();
        textSize(20);
        fill(0);
        text("bun", 215, 500);

    } else {
        noStroke();
        textSize(20);
        fill(0);
        text(":)", 225, 500);
    }
}



function mousePressed() {

    earWidth = random(40, 75);
    earLength = random(140,200);

   	eyeColorR = random(0,255);
   	eyeColorG = random(0,255);
   	eyeColor = random(0,255);

   	noseWidth = random(25,40);
   	noseLength = random(10,20);

   	word = random(0,4);
   	wordNumber = random(0,4);

 }

This was a very fun project and a great introduction to variables! Since we had already coded a human face for the previous project, I wanted to do something different this time and created a simple drawing of an animal. (a bunny – my favorite!) It took a lot less time than expected!

Leave a Reply