xxxxxxxxxx
157
let buttonText = "click on me!"; //to display the text on the screen
let isSmiling = false; //variable to check if smiling or not
let isBlushing = false; //variable to check if blushing or not
function setup() {
createCanvas(400, 390);
}
function draw() {
background(245, 231, 120);
//hair
fill(0)
circle(210, 165, 300)
//hairband
stroke(213, 222, 224)
strokeWeight(5.5)
noFill()
//hair
circle(210, 165, 260)
fill(0)
noStroke()
rect(60, 160, 300, 160, 20);
stroke(0)
strokeWeight(1)
fill(230, 197, 179);
//neck
fill(230, 197, 179);
rect(185, 267, 45, 50);
//face
ellipse(210, 160, 220, 220)
fill(230, 197, 179);
//left eye
strokeWeight(1);
if (isSmiling) {
arc(160, 175, 50, 50, PI, TWO_PI); //eye when smiling
} else {
fill(255);
ellipse(160, 160, 50, 50); //default eye shape
}
//right Eye
strokeWeight(1);
if (isSmiling) {
arc(260, 175, 50, 50, PI, TWO_PI); //eye when smiling
} else {
fill(255);
ellipse(260, 160, 50, 50); //default eye shape
}
//iris
if (!isSmiling) {
stroke(48, 40, 35);
strokeWeight(3);
fill(48, 43, 39)
ellipse(160, 160, 30, 30);
ellipse(260, 160, 30, 30);
}
//eyelashes for the left eye
stroke(0);
strokeWeight(2); //thickness of the eyelashes
if (!isSmiling) {
line(168, 127, 165, 134.5);
line(159, 134, 159, 125);
line(153, 135, 150, 127);
}
//eyelashes for the right eye
if (!isSmiling) {
line(260, 126, 260, 134)
line(254, 135, 251, 126);
line(266, 135, 269, 125);
}
//nose
strokeWeight(1);
fill(230, 197, 179);
ellipse(210, 190, 15, 15);
//nostrils
strokeWeight(1);
fill(0,200);
ellipse(205, 194, 2, 2);
ellipse(215, 194, 2, 2);
//mouth
stroke(0);
strokeWeight(1);
noFill();
beginShape();//shape changes upon clicking on screen
if (isSmiling) {
curveVertex(180, 218);
curveVertex(180, 218);
curveVertex(208, 235);
curveVertex(236, 218);
curveVertex(236, 218);
} else {
curveVertex(181, 223);
curveVertex(181, 223);
curveVertex(208, 225);
curveVertex(236, 223);
curveVertex(236, 223);
}
endShape();
//shirt
fill(195, 214, 247);
arc(210, 390, 200, 200, PI, 0)
//shirt's neckhole
fill(230, 197, 179);
arc(207.5, 285, 44, 44, 0, PI);
//blush on cheeks
if (isBlushing) {
fill(247, 195, 195);
noStroke();
ellipse(146, 210, 25, 25); //left cheek
ellipse(274, 210, 25, 25); //right cheek
}
//ears
noStroke()
fill(230, 197, 179);
ellipse(105, 180, 20, 20); //left Ear
ellipse(314, 180, 20, 20); //right Ear
//text
c = color('white');
fill(c);
text(buttonText, 22, 52);
stroke(0);
noFill();
//middle parting (took this part of code from the internet)
fill(0);
rotate(2/3);
ellipse(270, -90, 150, 50);
rotate(1/3);
ellipse(160, -80, 50, 150)
}
function mousePressed() {
isSmiling = !isSmiling; //toggle
isBlushing = !isBlushing; //toggle
}