Skip to main content
100%

Voronoi relaxation

✓ Published0🌍 Public
TThanaporn-sk
Last edited Apr 4, 2017
Created on Apr 4, 2017

A hundred random points relax into a stable Voronoi diagram using Lloyd’s algorithm, with each iteration fading the previous frame on a Canvas. The example runs entirely in the browser via D3 v4’s `d3.voronoi()` for polygon generation and `d3.polygonCentroid` to compute new point positions. The code animates convergence through `setTimeout` recursive calls, drawing point markers and polygon edges with the Canvas 2D API, and uses `getImageData()` to progressively darken old frames. Once points move less than one pixel, the visualization resets with a fresh random distribution.

AI-generated description

Voronoi relaxation with Lloyd's algorithm in d3 4.0.

forked from <a href='http://bl.ocks.org/veltman/'>veltman</a>'s block: <a href='http://bl.ocks.org/veltman/3d1fb70e6993d4eb2eff7112c9e7bcf4'>Voronoi relaxation</a>

mit Licensed

Similar vizzes