Skip to main content
100%

Voronoi.find(x,y)

✓ Published0🌍 Public
PPhilippe Rivière
Last edited Oct 28, 2016
Created on Aug 26, 2016

The example demonstrates how `voronoi.find(x,y)` locates the nearest cell in a Voronoi diagram as the mouse moves. A red fill marks the found cell, while orange and yellow highlight cells visited and tested during the search, revealing the algorithm’s traversal path. The code uses d3.v4 with 1000 random sites, rendering polygons as SVG paths. It wraps the native `diagram.find` method (available since v4.3.0) to add the color-coding, and applies a 50-pixel radius search limit.

AI-generated description

voronoi.find(x,y) finds the nearest cell to the point (x,y).

  • Red: found<br>
  • Orange: used<br>
  • Yellow: tested

Usage:

 

Original work by Philippe Rivière for d3-voronoi (available since v4.3.0).

See also the Spherical geoVoronoi.find().

Voronoi tesselation forked from <a href='http://bl.ocks.org/mbostock/'>mbostock's block</a>.

gpl-3.0 Licensed

Similar vizzes