Minjae Jeong-Project 02-Variable Face

sketch

//Minjae Jeong
//Section B
//minjaej@andrew.cmu.edu
//Project-02-Variable-Face

var backgroundR = 181;
var backgroundG = 100;
var backgroundB = 227;
var faceR = 116;
var faceG = 209;
var faceB = 157;
var faceW = 300;
var faceH = 250;
var eyeW = 100;
var eyeH = 130;
var pupilW = 50;
var pupilH = 50;
var mouthW = 200;
var mouthH = 120;

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

function draw() {
    background(backgroundR/2, backgroundG/2, backgroundB/2);
    noStroke();
    //face
    fill(faceR,faceB,faceB);
    ellipse(240, 300, faceW,  faceH);
    //eyes & pupils
    fill(255, 224, 224);
    ellipse(120 ,280, eyeW/2 + 30, eyeH/2);
    ellipse(320, 280, eyeW/2 + 30, eyeH/2);
    fill(0);
    ellipse(120, 280, pupilW, pupilH);
    ellipse(320, 280, pupilW, pupilH);
    //mouth
    fill(255);
    arc(240, 340, mouthW, mouthH, 0, PI);

}

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.
    backgroundR = random(150, 200);
    backgroundG = random(50, 150);
    backgroundB = random(180, 255);
    faceR = random(100, 140);
    faceG = random(200, 240);
    faceB = random(170, 190);
    faceW = random(300, 400);
    faceH = random(225, 275);
    eyeW = random(60, 100);
    eyeH = random(80, 120);
    pupilW = random(20, 50);
    pupilH = random(20, 50);
    mouthW = random(160,200);
    mouthH = random(70, 150);
}

Happy weekend

Leave a Reply