xxxxxxxxxx
const sketch = {
fps: 30, // frames per second
fpp: 240, // frames per period
};
function theta() {
return ((frameCount - 1) / sketch.fpp) * TAU;
}
function duration() {
return sketch.fpp / sketch.fps;
}
function setup() {
createCanvas(600, 600);
colorMode(HSB);
frameRate(sketch.fps);
}
function astroid(t) {
return {
x: pow(cos(t), 3),
y: pow(sin(t), 3)
}
}
function draw() {
const baseHue = 342;
const bg = color([baseHue, 20, 10]);
background(bg);
translate(width / 2, height / 2);
const m = 120;
const t = theta();
fill([baseHue, 20, 100, 0.05]);
strokeWeight(2);
const sb = 44;
for (let s = 0.5; s <= 13; s += 0.5) {
rotate(map(sin(t), -1, 1, PI / 1.5, PI))
scale(map(sin(t), -1, 1, 0.75, 1.0));
stroke([baseHue, map(s, 1, 13, 20, 80), map(s, 1, 13, 20, 80)]);
beginShape();
for (let i = 0; i < m; i += 1) {
const {
x,
y
} = astroid(i);
curveVertex(s * sb * x, s * sb * y);
}
endShape();
}
}