TamiTedesco-Project-02-VariableFace

sketch

//Tami Tedesco
//Section 1 (9:30)
//ttedesco@andrew.cmu.edu
//Project-02

var eyeSize = 20;
var faceWidth = 100;
var faceHeight = 150;
var mouthHeight = 80;
var mouthWidth = 80;
var browWidth = 25;
var browHeight = 5;
var rectCorner = 20;
 
function setup() {
    createCanvas(300, 300);
    //random color fill
    r = random(255);
    g = random(255);
    b = random(255);
}
 
function draw() {
    background('#FBFF98');
    strokeWeight(4);
    //head
    fill(r, g, b, 127);
    rect(width / 2, height / 2, faceWidth,  faceHeight, rectCorner);
    fill(51);
    var eyeLX = width / 2 - faceWidth * 0.25;
    var eyeRX = width / 2 + faceWidth * 0.25;
    ellipse(eyeLX, height / 2, eyeSize, eyeSize);
    ellipse(eyeRX, height / 2, eyeSize, eyeSize);
    //mouth
    fill('#FFFFFF')
    arc(150, 175, mouthWidth, mouthHeight, 0, PI, CHORD);
    //eyebrows
    //L
        fill('#000000')
        rectMode(CENTER);
        translate(width/2, height/2);
        rotate(HALF_PI/3.0);
        rect(-35, -10, browWidth, browHeight);
    //R
        fill('#000000')
        rectMode(CENTER);
        rotate(-PI/3.0);
        rect(35, -10, browWidth, browHeight)
}
 
function mousePressed() {
    
    r = random(255);
    g = random(255);
    b = random(255);
    faceWidth = random(70, 150);
    faceHeight = random(100, 200);
    eyeSize = random(10, 30);
    mouthWidth = random(20, faceWidth);
    mouthHeight = random(20, faceHeight/2);
    browWidth = random(20, 40);
    browHeight = random(2, 15);
    rectCorner = random(0, 250)

}

So this is my variable face program! It generates a randomly colored face making different degrees of the >:D emoticon, which is one I use a lot when I text. In addition, the face shape, mouth size, eye size, and eyebrow size are all also randomly generated. The character of the >:D expression changes a bit depending on the facial structure behind it, so I wanted to explore that aspect with this program.

Author: Tami Tedesco

I'm an English major and I like cats and classic lit :U

Leave a Reply