Variable Face
var faceWidth = 200
var faceHeight = 300
var faceColor = 255
var eyeSize = 40
var eyeL = 20
var eyeR = 20
var r = 0
var g = 0
var b = 0
var mouth = 1
function setup() {
createCanvas(480,640);
}
function draw() {
background(180);
//head
fill(r,g,b);
ellipse(width/2,height/2,faceWidth, faceHeight);
//eyeballs
fill(255);
ellipse(eyeL,height/2,50,30); //left
ellipse(eyeR,height/2,50,30); //right
//pupil ellipse
fill(111, 78, 55);
ellipse(eyeL,height/2,20,20); //left
ellipse(eyeR,height/2,20,20); //right
//nose
fill(255);
stroke(0,0,0);
strokeWeight(1);
if(eyeL<=width/2-faceWidth/4 & eyeR<=width/2+faceWidth/4){
triangle(width/2, height/2, width/2, height/2+faceHeight/5, width/2-faceWidth/4, height/2+faceHeight/8); //left
}else if(eyeL>=width/2-faceWidth/4 & eyeR>=width/2+faceWidth/4){
triangle(width/2, height/2, width/2, height/2+faceHeight/5, width/2+faceWidth/4, height/2+faceHeight/8); //right
}else{
triangle(width/2, height/2, width/2+faceWidth/8, height/2+faceHeight/5, width/2-faceWidth/8, height/2+faceHeight/5); //mid
}
//mouth
if(mouth == 1){
fill(0);
arc(width/2,height/2+faceHeight/4,70,50,0,PI,CHORD); //happy
noFill();
strokeWeight(3);
arc(eyeL,height/2-30,70,40,PI,2*PI);
arc(eyeR,height/2-30,70,40,PI,2*PI);
strokeWeight(1);
}else if(mouth == 2){
fill(225,0,0);
arc(width/2,height/2+faceHeight/3,70,50,PI,2*PI,CHORD); //mad
stroke(255,0,0);
strokeWeight(5);
line(eyeL-25,height/2-40,eyeL+25,height/2-20);
line(eyeR+25,height/2-40,eyeR-25,height/2-20);
stroke(0);
strokeWeight(1); //resets stroke
}else if(mouth==3){
fill(0);
ellipse(width/2,height/2+faceHeight/3,30,30); //scared
strokeWeight(3);
line(eyeL-25,height/2-20,eyeL+25,height/2-40);
line(eyeR+25,height/2-20,eyeR-25,height/2-40);
strokeWeight(1);
}
}
function mousePressed(){
faceWidth = random(180,300);
faceHeight = random(200,340);
faceColor = random(0,255);
eyeL = random(width/2-faceWidth/2+25,width/2-25);
eyeR = random(width/2+25,width/2+faceWidth/2-25);
r = random(0,255);
g = random(0,255);
b = random(0,255);
mouth = int(random(1,4));
}
//don't mind the stuff down here
//mouth
//line(200,290,280,290);
//pupil with points
//stroke(111, 78, 55);
//strokeWeight(20);
//point(190,190);
//point(280,190);
//sunglasses and frame
// stroke(255,0,0);
// strokeWeight(3);
// line(320,220,350,190);
// fill(180,240,0);
// rect(130,200,90,50);
// fill(50,158,200);
// rect(230,200,90,50);
//background ellipses
//fill(255,230,0);
//ellipse(250,200,500,600);
//fill(196,80,71);
//ellipse(250,200,400,500);
//fill(147,248,234);
//ellipse(250,200,330,430);
//fill(135,73,146);
//ellipse(250,200,270,370);
//fill(0,0,0);
//ellipse(250,200,230,330);