Project-02-Variable Face

sketch9.12.2Download
// Amyas Ryan Section A
var eyeSize = 20;
var faceWidth = 100;
var faceHeight = 150;
var mouthSize = 60;
var browSize = 30;

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

function draw() {
    background(226, 146, 170);
    fill(60, 200, 72);
    ellipse(width / 2, height / 2, faceWidth,  faceHeight);
    var eyeLX = width / 2 - faceWidth * 0.25;
    var eyeRX = width / 2 + faceWidth * 0.25;
    var mouth = width / 2
    var browL = width / 2 - faceWidth * 0.25;
    var browR = width / 2 + faceWidth * 0.25;
    arc(240, 360, 60, 40, 0, 180);
    fill(255, 255, 255);
    ellipse(eyeLX, height / 2, eyeSize, eyeSize);
    ellipse(eyeRX, height / 2, eyeSize, eyeSize);
    fill(30, 170, 42);
    ellipse(mouth, height / 2 + 100, mouthSize + 20, mouthSize);
    fill(0, 0, 0);
    rect(browL, height / 2 - 40, browSize, browSize / 2);
    rect(browR - 10, height / 2 - 40, browSize, browSize / 2);
}

function mousePressed() {
    faceWidth = random(150, 300);
    faceHeight = random(300, 500);
    eyeSize = random(10, 30);
    mouthSize = random(20, 70);
    browSize = random(10, 40);
}

Leave a Reply