Project 2 – Variable Faces

For my variable face project, I chose to randomize chicken faces! This project seemed difficult at first, but after studying the sample code template, I had a better understanding of how and where to assign and use variables. My biggest challenge was figuring out how to randomize the chicken beak, since the code for a triangle consists of six coordinates; I had to figure out which coordinates to randomize and which coordinates to stay constant (so the beak doesn’t fly around the canvas). Overall, however, this project was quite fun and I think my chicken turned out reallyyyy cute 😀

Maggie-Variable Faces
var eyeSize = 15;
var faceWidth = 200;
var faceHeight = 300;
var beakWidth = 18;
var beakHeight = 30;
var cheekSize = 20;
var crown1Size = 40;
var crown2Size = 30;
var r=133;
var g=217;
var b=92;
function setup() {
    createCanvas(500, 500);
}
 
function draw() {
    background(r,g,b);
    noStroke();
    //face
    fill(255,255,255);
    ellipse(width / 2, height / 2, faceWidth,  faceHeight);
    //eyes
    fill(0, 0 ,0);
    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);
    //beak
    fill (239,128,9);
    triangle((width/2) - (beakWidth/2),height/2, width/2, height/2 + beakHeight,(width/2) + (beakWidth/2), height/2);
    //cheek
    fill (243,187,200);
    var cheekLX = width/2 - faceWidth/3;
    var cheekRX = width/2 + faceWidth/3;
    ellipse(cheekLX, height /2 + 25, cheekSize, cheekSize);
    ellipse(cheekRX, height/2 +25, cheekSize, cheekSize);
    //crown 1
    fill(247,86,79);
    var crownLX = width/2 - 10;
    var crownRX = width/2 + 10;
    ellipse(crownLX, height/2 - 70, crown1Size, crown1Size);
    ellipse(crownRX, height/2 - 70, crown2Size, crown2Size);


}
 
function mousePressed() {
    r = random(110, 200);
    g = random(50,217);
    b = random(50, 200);
    faceWidth = random(130, 320);
    faceHeight = random(120, 350);
    eyeSize = random(6, 22);
    beakWidth =random(15, 40);
    beakHeight = random(15,20);
    cheekSize = random (15, 30);
    crown1Size = random(40,65);
    crown2Size = random(30, 70);
}


	

Leave a Reply