xxxxxxxxxx
48
//By AnonymousPyro
//Inspired from CodingTrain!!
let angle = 0;
let heart = [];
let c;
let counter = 0;
function setup() {
c = createCanvas(windowWidth, windowHeight);
}
function draw() {
background(180, 0, 50, 30);
//save(c,`HEART-${counter}.jpg`);
translate(width / 2, height / 2);
fill(255, 0, 50);
strokeWeight(4);
noFill();
stroke(255, 0, 50);
let scl = map(sin(angle),0,1,0.9,1);
scale(scl);
if (angle < TWO_PI) {
let r = map(pow(sin(angle), 1), 0, 1, 8, 10);
let x = -1.5 * (16 * pow(sin(angle), 3));
let y = -1.5 * (13 * cos(angle) - 5 * cos(2 * angle) - 2 * cos(3 * angle) - cos(4 * angle));
heart.push(createVector(r * x, r * y));
}
if (angle > TWO_PI) {
heart.shift();
if (heart.length == 0) {
angle = 0;
}
}
beginShape();
for (let pt of heart) {
vertex(pt.x, pt.y);
}
endShape();
angle += 0.05;
counter += 1;
}