xxxxxxxxxx
114
function setup() {
createCanvas(500, 500);
}
function draw() {
if (keyIsPressed == true) {
if (keyCode == 66) {
blink();
}
else if (keyCode == 83)
scream();
}
else if (mouseIsPressed == true) {
animation();
}
else {
standard();
}
}
function standard() {
background("yellow");
fill("white");
//mouth
arc(250, 250, 350, 350, TWO_PI, radians(180));
stroke(5)
//eyes
circle(150, 150, 100);
circle(350, 150, 100);
//pupils
fill("black");
circle(150, 150, 25);
circle(350, 150, 25);
//face
noFill();
strokeWeight(5);
circle(250, 250, 450);
}
function animation() {
background("red");
fill("black");
//mouth
arc(250, 250, 350, 350, TWO_PI, radians(180));
stroke(5)
//eyes
triangle(150, 105, 125, 175, 175, 175);
triangle(350, 105, 325, 175, 375, 175);
//face
noFill();
strokeWeight(5);
circle(250, 250, 450);
}
function scream() {
background("yellow");
fill("white");
//mouth
arc(250, 250, 350, 350, TWO_PI, radians(180));
stroke(5)
//eyes
circle(150, 150, 100);
circle(350, 150, 100);
//pupils
fill("red");
circle(150, 150, 25);
circle(350, 150, 25);
//face
noFill();
strokeWeight(5);
circle(250, 250, 450);
}
function blink() {
background("yellow");
fill("white");
//mouth
arc(250, 250, 350, 350, TWO_PI, radians(180));
stroke(5)
//eyes
fill ("black");
rect(100, 150, 100, 20);
rect(300, 150, 100, 20);
//face
noFill();
strokeWeight(5);
circle(250, 250, 450);
}