SydneyCha-Project-02-Variable-Face

sketch
//Sydney Cha
//Section D

var eyeSize = 20;
var faceWidth = 100;
var faceHeight = 150;

var r = 207;
var g = 185;
var b = 151;

var re = 100;
var ge = 100;
var be = 100;
 
function setup() {
    createCanvas(300, 300);
}
 
function draw() {
    background(re);

    ellipse(width / 3, height / 2, faceWidth / 3, faceWidth / 3); //left ear
    ellipse(2*width / 3, height / 2, faceWidth / 3, faceWidth / 3); //right ear

    fill(r, g, b);
    ellipse(width / 2, height / 2, faceWidth,  faceHeight); //face

    var eyeLX = width / 2 - faceWidth * 0.25;
    var eyeRX = width / 2 + faceWidth * 0.25;
    fill(re, ge, be);
    ellipse(eyeLX, height / 2, 2*eyeSize/3, 2*eyeSize); //left eye
    ellipse(eyeRX, height / 2, 2*eyeSize/3, 2*eyeSize); //right eye

    fill(200, 70, 70);
    arc(width / 2, 2*height / 3, 20, 10, TWO_PI, PI); //mouth

    line(width / 2, height / 2, width / 2, faceHeight - 10); //nose
}
 
function mousePressed() {
    faceWidth = random(100, 120);
    faceHeight = random(130, 200);
    eyeSize = random(10, 30);

    r = random(160, 240);
    g = random(180, 200);
    b = random(150, 180);

    re = random(95, 255);
    ge = random(95, 255);
    be = random(95, 255);
}

Leave a Reply