simulation = {
more;
const simulation = d3
.forceSimulation(nodes)
.force(
"collide",
d3
.forceCollide()
.radius((d) => {
return d.r * 0.96;
})
.strength(0.1)
)
.alpha(alpha)
.alphaDecay(0.0001)
.velocityDecay(0.001)
.on("tick", () => {
nodes.forEach((n) => {
const newVelocity = 0.5;
n.r += 0.12;
if (chance.bool()) n.vx += chance.floating({ min: -0.1, max: 0.1 });
if (chance.bool()) n.vy += chance.floating({ min: -0.1, max: 0.1 });
const nodeColor = d3.hcl(n.color);
nodeColor.h += chance.floating({ min: -0.18, max: 0.18 });
nodeColor.l -= chance.floating({ min: -0.2, max: 0.2 });
n.color = nodeColor.hex();
let goodX = Math.max(n.r, Math.min(width - n.r, n.x));
let goodY = Math.max(n.r, Math.min(width - n.r, n.y));
});
});
return simulation;
}