xxxxxxxxxx
37
function setup() {
//createCanvas is (width, height)
createCanvas(600, 400);
}
function draw() {
background(220);
// Draw face
fill("#FFDF00");
noStroke();
circle(width / 2, height /2, height);
// Draw both eyes
drawEye(220, 150);
drawEye(220+150, 150);
// Draw mouth
fill("red");
let mouthHeight = map(mouseY, 0, height, 0, 100);
rect(200, 250, 200, mouthHeight);
noStroke();
fill("black");
text(nf(frameRate(), 1, 1) + " fps", 10, 14);
}
function drawEye(x, y){
// Draw left eye
stroke("black");
fill("white"); // fill(255)
ellipse(x, y, 80, 60);
// Draw left eye pupil
fill("black");
circle(x, y + 10, 20);
}