class Heart{ constructor(x, y){ this.pos = createVector(x, y); this.pulse = 0; this.size = random(50, 200); } update(){ this.pulse += 0.1; this.pulseValue = 1 + 0.03 * sin(this.pulse); } show(){ function heart(x, size){ return size * sqrt(1 - abs(x) / size); } push(); translate(this.pos.x, this.pos.y); scale(this.pulseValue); fill(255, 0, 0, 80); noStroke(); arc(this.size / 4, 0, this.size / 2, this.size / 2, PI, TWO_PI); arc(-this.size / 4, 0, this.size / 2, this.size / 2, PI, TWO_PI); beginShape(); vertex(-this.size / 2, 0); for (let x = -this.size / 2; x < this.size / 2; x++){ vertex(x, heart(x, this.size / 2)); } vertex(this.size / 2, 0); endShape(); pop(); } }