Project-02: Variable Faces

project-02-variableFaces-lkenny
// Lauren Kenny (lkenny)
// Project 2 - Variable Faces
// Section A

var r = 220;
var g = 220;
var b = 220;
var faceWidth  = 100;
var faceHeight  = 100;
var leftEyeSize = 10;
var rightEyeSize = 10;

function setup() {
    createCanvas(640, 480);
    r = random(256);
    g = random(256);
    b = random(256);
}

function draw() {
    background(r, g, b);
    //ears
    fill(r+50, g+50, b+50);
    stroke(r-50, g-50, b-50);
    ellipse(((width/2)-(faceWidth/2)), (height/2), faceWidth/6, faceHeight/6);
    ellipse(((width/2)+(faceWidth/2)), (height/2), faceWidth/6, faceHeight/6);
    //face
    fill(r+50, g+50, b+50);
    stroke(r-50, g-50, b-50);
    strokeWeight(2);
    ellipse(width/2, height/2, faceWidth, faceHeight);
    //eyes
    ellipse(width/2-20, height/2-20, leftEyeSize, leftEyeSize);
    ellipse(width/2+20, height/2-20, rightEyeSize, rightEyeSize);
    //pupils
    fill(r-50, g-50, b-50);
    noStroke();
    ellipse(width/2-20, height/2-20, leftEyeSize/5, leftEyeSize/5);
    ellipse(width/2+20, height/2-20, rightEyeSize/5, rightEyeSize/5);
    //body
    fill(r+50, g+50, b+50,)
    stroke(r-50, g-50, b-50);
    rect((width/2)-(faceWidth/2), (height/2)+(faceHeight/2)+15, faceWidth, ((height)-(faceHeight)-15), 50, 50);
    //lips
    fill(r+75, 20, 20);
    noStroke();
    arc((width/2-(faceWidth/10)/3), height/2+25, faceWidth/8, faceHeight/10, PI, TWO_PI);
    arc((width/2+(faceWidth/10)/3), height/2+25, faceWidth/8, faceHeight/10, PI, TWO_PI);
    fill(r+95, 50, 50);
    arc((width/2), (height/2+25), faceWidth/6, faceHeight/12, 0, PI);
    //nose
    noFill();
    stroke(r-50, g-50, b-50);
    arc(width/2, height/2, faceWidth/6, 10, 0, PI, OPEN);
}

function mousePressed(){
    r = random(5, 256);
    g = random(5, 256);
    b = random(5, 256);
    faceWidth = random(75, 165);
    faceHeight = random(75, 200);
    leftEyeSize = random(5, 30);
    rightEyeSize = random(5, 30);
}








Leave a Reply