aspectRatio = {
await visibility();
const context = DOM.context2d(width, height);
const nodes = d3.range(500).map(() => ({}));
const simulation = d3
.forceSimulation(nodes)
.force("x", d3.forceX(width / 2).strength(0.1))
.force("y", d3.forceY(height / 2).strength((0.2 * width) / height))
.force("collide", d3.forceCollide(11.5).iterations(4))
.on("tick", ticked);
function ticked() {
context.clearRect(0, 0, width, height);
context.save();
context.strokeStyle = "steelblue";
context.rect(20, 20, width - 20 - 20, height - 20 - 20);
context.stroke();
for (const { x, y } of nodes) {
context.beginPath();
context.arc(x, y, 10, 0, 2 * Math.PI);
context.fill();
}
context.restore();
}
invalidation.then(() => simulation.stop());
return context.canvas;
}