/*
* Angela Lee
* Section E
* ahl2@andrew.cmu.edu
* Assignment-02
*/
// variables for eye size, face width, and face height
var eye_size = 40;
var face_width = 200;
var face_height = 300;
var mouth_width = 30;
var mouth_height = 30;
var color_change = 0;
var mouth_change = 0;
function setup(){
createCanvas (480, 640);
}
function draw(){
background (230, 255, 255);
// body
fill (253, 255, 158);
ellipse (width / 2, height / 2 + face_height * 0.75, face_width, face_width);
rect (width / 2 - face_width / 2, height / 2 + face_height * 0.75, face_width, 400)
// face
noStroke ()
fill (255 - color_change, 217 - color_change, 177 - color_change);
ellipse (width / 2, height / 2, face_width, face_height);
// variables for eye position
var left_eye = width / 2 - face_width * 0.25;
var right_eye = width / 2 + face_width * 0.25;
// eyes
noStroke ()
fill ("black")
ellipse (left_eye, height / 2, eye_size, eye_size);
ellipse (right_eye, height / 2, eye_size, eye_size);
// highlights of the eyes
fill ("white")
ellipse (left_eye + eye_size / 5, height / 2 - eye_size / 5, 10, 10)
ellipse (right_eye + eye_size / 5, height / 2 - eye_size / 5, 10, 10)
// creating mouth
noStroke ()
fill (222 - mouth_change, 81 - mouth_change, 73 - mouth_change)
ellipse (width / 2, height / 2 + 0.25 * face_height, mouth_width, mouth_height);
}
function mousePressed() {
face_width = random (175, 300);
face_height = random (175, 300);
eye_size = random (30, 50);
mouth_width = random (40, 80);
mouth_height = random (30, 50);
color_change = random (0,150);
mouth_change = random (0, 50);
}
I started this project feeling slightly intimidated since I had no idea how you could create faces that changed. I went through a couple of iterations to get to this final product; being able to visually see mistakes really helped me adjust my shapes. This project helped me experience how powerful variables and built-in functions such as random can be. One thing I had fun playing with was randomizing color but also adhering to a skin tone palette—I hope to experiment more with randomization of color in the future.