//Sophia Qin
//15-104 Section B
//sophiaq@andrew.cmu.edu
//Project-02
var eyeSize = 20;
var faceWidth = 200;
var faceHeight = 250;
var eyeBrowHeight = 50;
var color = 50;
var hair = 30;
function setup() {
createCanvas(640, 480);
}
function draw() {
//structure of the face
background(255,color,0);
//face is mid of canvas
fill(0,0,color);
strokeWeight(5);
fill(color,200,20);
ellipse(width/2,height/2,faceWidth,faceHeight);
//eye position
var eyeLX = width/2-faceWidth*0.25;
var eyeRX = width/2+faceWidth*0.25;
//drawing eye
fill(50);
ellipse(eyeLX, height / 2, eyeSize, eyeSize);
ellipse(eyeRX, height / 2, eyeSize, eyeSize);
//minieye
fill(255);
ellipse(eyeLX,height/2,eyeSize*0.5,eyeSize*0.5);
ellipse(eyeRX,height/2,eyeSize*0.5,eyeSize*0.5);
//eyebrow
noFill();
arc(eyeLX,height / 2,50,eyeBrowHeight, PI, 7/4*PI);
arc(eyeRX,height / 2,50,eyeBrowHeight,PI+QUARTER_PI,0);
//white mouth
fill(255);
ellipse(width/2, (height/2)+40,faceWidth/3,faceHeight/4);
//mouth inside
fill(color,0,10);
ellipse(width/2, (height/2)+40+(faceHeight/8),faceWidth/4,faceHeight/6);
//cheeks
fill(250,192,255)
ellipse(eyeLX,height/2+30,faceWidth/5,faceHeight/9);
ellipse(eyeRX,height/2+30,faceWidth/5,faceHeight/9);
//hair
fill(20,39,hair);
quad(width/2,height/2-(faceHeight/2)+30,(width/2)+faceWidth/2,height/2-(faceHeight/8),
eyeRX,faceHeight/2,eyeLX,faceHeight/2);
quad(width/2,height/2-(faceHeight/1.3),(width/2)+faceWidth/2,height/2-(faceHeight/1.3),
eyeRX,faceHeight/2,eyeLX,faceHeight/2);
quad(width/2+3,height/2-(faceHeight/1.3),(width/3)+faceWidth/3,height/2-(faceHeight/1.3),
eyeRX,faceHeight/2+3,eyeLX+30,faceHeight/2);
}
function mousePressed() {
//when the user clicks, the variables are reassigned
//to random values within specified ranges. For example,
//'face width' gets a random value between 75 and 150
faceWidth = random(230, 300);
faceHeight = random(220, 300);
eyeSize = random(10, 40);
eyeBrowHeight = random(30,80);
color = random(100,255);
hair = random(0,190);
}
I wanted the face shaped to be relatively similar and I wanted to look cartoony. I didn’t sketch out beforehand, and I figured out my plan of changing colors, sizes, hair, etc along the way