Skip to main content
100%

Voronoï playground: weighted Voronoï relaxation

✓ Published0🌍 Public
KKcnarf
Last edited Sep 14, 2017
Created on Aug 17, 2017

This interactive playground demonstrates Lloyd’s relaxation algorithm applied to weighted Voronoï sites. Through repeated iterations, each weighted cell’s centroid becomes its new site, converging to an equilibrium. Users can toggle between drawing the Voronoï cells or the weight circles, show or hide sites, and switch among greyscale, radial rainbow, or conical rainbow colorings. The code uses D3.js v.4, the d3-weighted-voronoi plugin, and Canvas rendering with custom gradients.

AI-generated description

This block experiments the Lloyd's relaxation algorithm on weighted sites.

This block is an adaptation of veltam's Voronoi relaxation block, which applies the algorithm to basic, non-weigthed, sites.

At each iteration

  • the weighted voronoi diagram is computed based on each weighted sites, thanks to the d3-weighted-voronoi plugin
  • then, each site is re-position at the center of its influence area

The algorithm stops when each site no longer moves (more exactly, when each site moves below a certain treshold).

User interactions :

  • you can choose to draw the Weighted Voronoï Diagram (default) or the weights (visualized as circles).
  • you can hide/show sites
  • you can choose among different rendering (greyscale, radial rainbow, or conical rainbow (default, having hard-&-fun time to implement it because canvas don't provides conical gradient)).

Acknowledgments to :

  • <a href='https://d3js.org/'>D3.js</a> (v.4)
  • <a href='https://github.com/Kcnarf/d3-weighted-voronoi'>d3-weighted-voronoi</a> plugin
  • <a href='http://blockbuilder.org'>blockbuilder.org</a>
  • <a href='http://bl.ocks.org/veltman/'>veltman</a>'s block: <a href='http://bl.ocks.org/veltman/3d1fb70e6993d4eb2eff7112c9e7bcf4'>Voronoi relaxation</a>, for the overall routine
mit Licensed

Similar vizzes