Jason Zhu-Project-02-Variable-Face

sketch

var eyeSize = 45;
var pupilSize = 15;
var faceWidth = 150;
var faceHeight = 150;
var mouthWidth = 10;
var mouthHeight = 10;
var skinColor = 250;
var hairColor = 142;
var hairHeight = 50;
var hairWidth = 50;
var bodyColor = 100;
var bodyAdjustor = 2.5
function setup() {
    createCanvas(300, 300);
}
 
function draw() {
    background(220,220,240);
    strokeWeight(0);
    //body
    var bodyPosition = width / 2 + bodyAdjustor
    fill(bodyColor, 150, 100);
    ellipse(bodyPosition, (height / 2) * 1.75, 200, 200);
    //Hair
    fill(hairColor, 150, 200);
    ellipse(width / 2, height / 3, faceWidth + 48, faceHeight + 22)
    //Face
    fill(skinColor, 220, 182);
    ellipse(width / 2, height / 2, faceWidth,  faceHeight);
    //Eyes
    fill(255);
    var eyeLX = (width / 2) * 1.09 - faceWidth * 0.25;
    var eyeRX = (width / 2) * .91 + faceWidth * 0.25;
    ellipse(eyeLX, height / 2, eyeSize, eyeSize);
    ellipse(eyeRX, height / 2, eyeSize, eyeSize);
    //Pupils
    fill(0);
    var PupilLX = (width / 2) * 1.09 - faceWidth * 0.25;
    var PupilRX = (width / 2) * .91 + faceWidth * 0.25;
    ellipse(PupilRX, height / 2, pupilSize, pupilSize);
    ellipse(PupilLX, height / 2, pupilSize, pupilSize);
    //Mouth
    fill(0);
    arc(width / 2, height / 1.5, mouthWidth, mouthHeight, TWO_PI, PI, OPEN);


}
 
function mousePressed() {
    // when the user clicks, these variables are reassigned
    // to random values within specified ranges. For example,
    // 'faceWidth' gets a random value between 75 and 150.
    eyeSize = random(35, 45);
    pupilSize = random(5, 15);
    mouthWidth = faceWidth / random(3, 10);
    mouthHeight = faceHeight / random(3, 10);
    skinColor = random(225, 255);
    hairColor = random(50, 220)
    bodyColor = random (0, 255)
    bodyAdjustor = random(-30, 30)
}

I found this assignment to be tremendously insightful as well as informative. I learned a lot about various principles such as the usage of variables as well as the randomization factor. Overall, this was an enjoyable and good assignment.

Leave a Reply