Skip to main content
100%

d3-voronoi.clipCircle

✓ Published0🌍 Public
KKcnarf
Last edited Jan 27, 2017
Created on Jan 27, 2017

This interactive visualization demonstrates how to programmatically clip a Voronoi tessellation to a circular boundary using d3.voronoi and custom geometry routines rather than relying on the browser’s screen-space clipping. As the user moves the mouse, the first site follows the pointer, dynamically recomputing the diagram and redrawing all polygon paths with a clipped `d` attribute. The code uses SVG, D3 v4, and functions like `segmentCircleIntersections` and `largeArc` to compute arc segments, with site positions generated from a random polar distribution inside the circle.

AI-generated description

This block experiments how to programmatically circle-clip a Voronoï tessellation, and does not rely on the browser to do the clipping in the screen space. This block follows the work done by Philippe Riviere in its Circular Bounded Voronoi Tessellation. Another experimentation is available in this block.

By default, d3.voronoi comes with a rectangular clipping, through the d3-voronoi.extent() API. This block shows another way to clip the initial tesselation.

The algorithm used in this block is basically a copy/paste of the algorithm used in the d3.distanceLimitedVoronoi d3 plugin I made. The two algorithms have distinct purposes: the plugin leverages UX by defining [interactive and not-too-far] areas around each site, whereas this block define a global clipping.

Acknowledgments to:

lgpl-3.0 Licensed

Similar vizzes