{
replay;
const context = DOM.context2d(width, width);
context.translate(width / 2, width / 2);
const points = [];
let t = 0;
const n = 200;
while (t < 1500) {
if (points.length < n && t % 5 === 0) {
const x = 0;
const y = 0;
const p = new Point(x, y, points.length);
points.push(p);
}
if (points.length === n) {
for (const point of points) {
point.final();
}
}
await Promises.delay(10);
context.clearRect(-width / 2, -width / 2, width, width);
for (let i = 0; i < points.length; ++i) {
points[i].move();
}
const delaunay = new d3.Delaunay(
points.reduce((acc, p) => [...p.pos, ...acc], [])
);
const voronoi = delaunay.voronoi([-width / 2, -width / 2, width, width]);
context.beginPath();
context.strokeStyle = "rgba(10,10,10,1)";
voronoi.render(context);
context.stroke();
context.beginPath();
delaunay.renderPoints(context, 1.5);
context.fill();
++t;
yield context.canvas;
}
}