Skip to main content
100%

Collision Detection

✓ Published0🌍 Public
Mmbostock
Last edited Jul 4, 2016
Created on Apr 25, 2016

A thousand circles of random radii are arranged into a tidy cluster, with d3.forceCollide preventing any overlap between them while d3.forceX and d3.forceY gently pull the whole group toward the center. The simulation runs on a fixed 960×960 canvas, where each tick clears the drawing and renders all circles as filled and stroked arcs. The code uses d3.forceSimulation with a velocity decay of 0.2, and draws the result directly via the Canvas 2D API.

AI-generated description

This example uses d3.forceCollide to prevent circles from overlapping.

gpl-3.0 Licensed

Similar vizzes