yoonyouk-project02-variablefaces
//Yoon Young Kim
//Section E
//yoonyouk@andrew.cmu.edu
//Project-02
var eyeLxSize = 40;
var eyeRxSize = 20;
var faceWidth = 240;
var faceHeight = 200;
var nose1x = 300;
var nose1y = 250;
var nose2x = 350;
var nose2y = 250;
var nose3x = 325;
var nose3y = 285;
var earpoint = 100;
var smileWidth = 25;
var smileHeight = 25;
//colors
var R1 = 232;
var R2 = 64;
var B1 = 33;
var B2 = 91;
var B3 = 237;
var Ye1 = 323;
var Ye2 = 204;
var Ye3 = 74;
var RW = 4 //weight of any red line
function setup() {
createCanvas(640, 480);
background(220);
angleMode(DEGREES);
}
function draw() {
background (B1, B2, B3);
//face
noStroke();
fill(Ye1, Ye2, Ye3);
ellipse (width/2, height/2 - 10, faceWidth, faceHeight)
//eyes
stroke(R1, R2, R2);
strokeWeight(RW);
noFill();
var eyeLX = width / 2 - faceWidth * 0.25;
var eyeRX = width / 2 + faceWidth * 0.25;
ellipse(eyeLX, height / 2, eyeLxSize, eyeLxSize);
ellipse(eyeRX, height / 2, eyeRxSize, eyeRxSize);
//triangle nose
noStroke();
fill(R1, R2, R2);
triangle(nose1x, nose1y, nose2x, nose1y, nose3x, nose3y);
//ears
//left ear
fill(Ye1, Ye2, Ye3);
triangle(220, 190, 225, earpoint, 310, 150);
//right ear
triangle(420, 190, 420, earpoint, 340, 150);
//mouth
stroke(R1, R2, R2);
strokeWeight(RW);
noFill();
arc(width / 2, height / 2 + faceWidth * 0.20, smileWidth, smileHeight, 0, 180);
}
function mousePressed() {
faceWidth = random(200, 300);
faceHeight = random(200, 275);
eyeLxSize = random(20, 80);
eyeRxSize = random(30, 60);
R1 = random(200, 250);
R2 = random(50, 100);
B1 = random(20, 70);
B2 = random(90 ,140);
B3 = random(200, 250);
Ye1 = random(300, 350);
Ye2 = random(180, 230);
Ye3 = random(50, 100);
RW = random(7, 15);
smileWidth = random(40, 80);
smileHeight = random(20, 50);
nose1x = random(270, 300);
nose1y = random(240, 260);
nose2x = random(320, 350);
nose3x = random(300, 325);
nose3y = random(270, 285);
earpoint = random(50, 120);
}
Much like the first project, I felt that this project required a lot of playing around and trial and error. I wanted to use primary colors in order to range the different color values to evict a childish type of project. In order to experiment with different shapes, I decided to go with a cat face. I like how each image generates a new combination/a new cat face upon each click.