xxxxxxxxxx
95
//Yao Xiao
//Form Generator
let f1;
let f2;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(255);
strokeWeight(8);
push();
translate(10, 10);
scale(0.9 + sin(frameCount * 0.1) * 0.05);
Heart();
pop();
push();
textSize(25);
fill(255, 153, 153);
text('How do you feel today?',65,50);
text('Try to click',130,380);
pop();
if (f1 == true) {
push();
let a = map(mouseX, 0, 500, 60, 250, true);
let b = map(mouseY, 0, 500, 100, 270, true);
translate(a, b);
Face1();
pop();
} else if (f2 == true) {
push();
let a = map(mouseX, 0, 500, 60, 250, true);
let b = map(mouseY, 0, 500, 100, 270, true);
translate(a, b);
Face2();
pop();
}
// if(!mouseIsPressed){
// f1 = f2 = false;
// }
}
function mousePressed() {
let Face = random(0, 2);
f1 = f2 = false;
if (Face < 1) {
f1 = true;
} else {
f2 = true;
}
}
function Face1() {
scale(0.7);
stroke(255, 179, 179);
fill(255, 179, 179)
ellipse(0, 0, 25, 40);
ellipse(100, 0, 25, 40);
noFill();
arc(50, 50, 30, 25, PI, 0);
}
function Face2() {
scale(0.7);
stroke(255, 179, 179);
fill(255, 179, 179)
ellipse(0, 0, 25, 40);
ellipse(100, 0, 25, 40);
noFill();
arc(50, 50, 30, 25, 0, PI);
}
function Heart() {
fill(255, 230, 238)
noStroke()
beginShape();
vertex(200, 350);
bezierVertex(300, 275, 350, 200, 350, 165);
bezierVertex(350, 100, 250, 50, 200, 140);
bezierVertex(150, 50, 50, 100, 50, 165);
bezierVertex(50, 250, 200, 350, 200, 350);
endShape();
}