Voronoi.find(x,y)
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 descriptionvoronoi.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>.