d3 / d3-voronoi

Compute the Voronoi diagram of a set of two-dimensional points.
Other
249 stars 60 forks source link

Feature request; polygon extent #25

Closed yurukov closed 7 years ago

yurukov commented 7 years ago

I have a viz I want to make where I have a map segmented along district lines. I have points in each district and want to do a voronoi segmentation of that district along certain points. I would like to use the district polygon outline as extent, instead of a triangle.

mbostock commented 7 years ago

I think it’s unlikely that we’re going to implement arbitrary clipping of 2D polygons, but if we do, it would be in the d3-polygon repo rather than here; see d3/d3-polygon#4. See also this JavaScript implementation of Greiner–Hormann.

Alternatively, you can use SVG or Canvas clipping to clip the Voronoi diagram rather than doing it in JavaScript.

yurukov commented 7 years ago

I agree, that's what I ended up doing - clipping the paths with the region path.