Public
Edited
Feb 2, 2023
1 star
Insert cell
Insert cell
Insert cell
p5((s) => {
let system, k, offset, bg, cnt;

// Color
bg = getColor();

s.setup = function () {
s.createCanvas(W, H);
k = 0;
cnt = 0;
s.noStroke();
};

s.draw = function () {
s.background(bg);

for (let n = 0; n < k; n++) {
s.fill(sgs[n].clr);
s.push();
s.translate(sgs[n].x, sgs[n].y);
s.rotate(s.TWO_PI * (sgs[n].itr * 0.01) * (cnt / 360.0));
offset = -sgs[n].r * 0.5;
s.rect(offset, offset, sgs[n].r, sgs[n].r);
s.pop();

// updates
if (sgs[n].r < 1000) {
sgs[n].r += 6;
} else {
sgs[n].r = 50;
}
}
if (cnt % 10 == 0 && k < sgs.length) {
k++;
}
if (k > sgs.length) {
k = 0;
}
cnt += 1.0;
};
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
W = form.width
Insert cell
H = form.height
Insert cell
Insert cell
Insert cell
Insert cell
import { p5 } from "@tmcw/p5"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more