// Isabella Hong
// Section A
// ijhong@andrew.cmu.edu
// Project-02
// eye color and placement
var I = 25;
// pupils
var p = 15;
//eye color
var eyeColorR = 255;
var eyeColorG = 255;
var eyeColorB = 255;
//skin color
var skinColorR = 255;
var skinColorG = 229;
var skinColorB = 180;
//nose color
var nColorR = 255;
var nColorG = 229;
var nColorB = 180;
//mouth size
var m = 12;
//surprise lines thickness
var sl = 10;
function setup() {
createCanvas(640, 480);
}
function draw() {
background(255);
//face
noStroke();
fill(skinColorR, skinColorG, skinColorB);
ellipse(width / 2, height / 2.3, 200, 250);
//eyes
noStroke();
fill(eyeColorR, eyeColorG, eyeColorB);
var ILX = width / 2 - 200 * 0.25;
var IRX = width / 2 + 250 * 0.25;
ellipse(ILX - 40, height / 2.5, I, I + 10);
ellipse(IRX - 80, height / 2.5, I, I + 10);
//pupils
noStroke();
fill(0);
ellipse(ILX - 40, height / 2.5, p - 5, p + 5);
ellipse(IRX - 80, height / 2.5, p - 5, p + 5);
//nose
stroke(255);
strokeWeight(5);
fill(nColorR, nColorG, nColorB);
triangle(260, 260, 202, 240, 260, 200);
//mouth
noStroke();
fill(231, 84, 128);
ellipse(270, 280, m, m);
//surprise lines
stroke(173, 216, 230);
strokeWeight(sl);
line(100, 100, 150, 150);
line(550, 100, 450, 150);
line(325, 60, 325, 5);
line(460, 240, 580, 240);
line(212, 100, 150, 15);
}
function mousePressed(){
//skin color changing
skinColorR = random(250, 255);
skinColorG = random(220, 255);
skinColorB = random(180, 255);
//eye color changing
eyeColorR = random(0, 255);
eyeColorG = random(0, 255);
eyeColorB = random(0, 255);
//eye size changing
I = random(35, 70);
//pupil size changing
p = random(20, 30);
//nose color changing
nColorR = random(0, 255);
nColorG = random(0, 255);
nColorB = random(0, 255);
//mouth size changing
m = random(12, 60);
//surprise lines thickness changing
sl = random(10, 25);
}
For Project 02, I decided to convey the emotion of surprise by assigning variables to various facial features and having them change to random colors and increase in size. I used the range 0-255 for all RGB colors to increase the unpredictability of what one would see after clicking upon the image.
The most difficult aspect of this project was making sure that I used all the variables correctly and my code was easily readable. Keeping my code organized was essential in order to ensure that I was changing the elements I intended to.