xxxxxxxxxx
53
let npoints = 100;
let radius;
let percent = 0;
let h = 0;
function setup() {
createCanvas(400, 400);
colorMode(HSB, 1, 1, 1, 1);
radius = width / 2 - 16;
}
function draw() {
background(0);
push();
translate(width / 2, height / 2);
var angle = TWO_PI / npoints;
stroke(255);
strokeWeight(4);
for (var a = 0; a < TWO_PI; a += angle) {
let ac = a;
let r = (1 - sin(ac)) * 0.66;
let numInnerHearts = 5
// cardioids
fill((h + a / TWO_PI) % 1, 1, 1, 0.3);
beginShape();
for (let i = 0; i < numInnerHearts; i++) {
r -= r * (i / numInnerHearts)
let cx = cos(ac) * r * radius;
let cy = ((sin(ac) * r) + 0.5) * radius;
let ah = PI / 2 - a;
let hx = 16 * pow(sin(ah), 3) * radius * 0.05;
let hy = (13 * cos(ah) - 5 * cos( 2 * ah) - 2 * cos(3 * ah) - cos(4 * ah)) * radius * 0.05;
let coef = sin(percent * PI);
let sx = cx * coef + hx * (1 - coef);
let sy = cy * coef + hy * (1 - coef);
vertex(sx, -sy);
}
endShape(CLOSE);
}
pop();
percent += 0.01;
if (percent >= 1)
{
percent = 0;
}
h += 0.003
}