Project-02

I started off using the baseline template for a generative face that was given. I then used multiple if else statements to randomize the use of the nose, round mouth, curved mouth, curved eyes, square eyes, and colors of the inner and outer shapes.

sketch

// Sowang Kundeling Section C Project 02

var r = 141;
var g = 35;
var b = 173;
var r2 = 210;
var g2 = 250;
var b2 = 233;
var eyeColor = 0
var faceWidth = 250;
var faceHeight = 300;
var eyeSize = 25;
var mouthWidth = 15;
var mouthPosition = 240;
 
function setup() {
    createCanvas(640, 480);
}
 
function draw() {
    background(166, 215, 227);
    noStroke();

    fill(r, g, b);
    ellipse(width/2, height/2, faceWidth+130, faceWidth+130); // hair

    if(faceHeight <= 125) {
        fill(r2, g2, b2);
        ellipse(width / 2, height / 2, faceWidth*.5, faceHeight*1.5); // cross ellipses
        ellipse(width / 2, height / 2, faceWidth*1.5, faceHeight*.5);
    }   

    fill(r2, g2, b2);
    ellipse(width / 2, height / 2, faceWidth,  faceHeight); // face shape
    var eyeLX = width / 2 - faceWidth / 4; // eye variables
    var eyeRX = width / 2 + faceWidth / 4;

    
    if(r <= 100) {
        fill(eyeColor);
        ellipse(eyeLX, (height / 2) - 5, eyeSize, eyeSize); // eye
        ellipse(eyeRX, (height / 2) - 5, eyeSize, eyeSize);
        fill(r2, g2, b2);
        ellipse(eyeLX, height / 2, eyeSize, (eyeSize / 2) + 9); // under eye shape to make arc
        ellipse(eyeRX, height / 2, eyeSize, (eyeSize / 2) + 9);
    } else {
        fill(eyeColor);
        rect(eyeLX -8, (height / 2) - 13, eyeSize/2, eyeSize/2); // square eye
        rect(eyeRX -8, (height / 2) - 13, eyeSize/2, eyeSize/2);
    }

    if(eyeColor <= 50) {
        fill(eyeColor);
        ellipse(width / 2, mouthPosition + 30, mouthWidth, mouthWidth); // round mouth
    } else {
        fill(eyeColor)
        ellipse(width / 2, mouthPosition + 30, mouthWidth + 5, mouthWidth); // arc mouth
        fill(r2, g2, b2);
        ellipse(width / 2, mouthPosition + 25, mouthWidth + 8 , mouthWidth +3); // shape to make arc
    }

    if(mouthPosition >= 240) { // nose
        fill(eyeColor);
        triangle(width/2, height/2, width/2 + 8, height/2 + 18, width/2 - 8, height/2 + 18);
    }
}
 
function mousePressed() {
    r = random(0, 199);
    g = random(0, 199);
    b = random(0, 199);
    r2 = random(200, 255);
    g2 = random(200, 255);
    b2 = random(200, 255);
    eyeColor = random(0, 100);
    faceWidth = random(75, 150);
    faceHeight = random(100, 150);
    eyeSize = random(20, 35);
    mouthWidth = random(10, 25);
    mouthPosition = random(220, 250);
}

Leave a Reply