Skip to main content
100%

Split an SVG path into pieces

✓ Published0🌍 Public
Aajayjayayy
Last edited Jul 26, 2018
Created on Jul 26, 2018

The visualization demonstrates how to split a single SVG path into 20 arbitrarily sized pieces, with each piece drawn as a separate colored segment. It first draws the full path with a stroke animation, then randomly divides the path into unequal portions and renders each segment sequentially with distinct colors and separator lines. The code uses D3 v4’s `d3.line` with `curveCardinal`, `getPointAtLength` to sample points along the path, and `transition` with delays to reveal pieces in sequence. A step-by-step instruction list highlights each phase of the process.

AI-generated description

This is an example of how to split an SVG path into an arbitrary number of pieces.

It is the technique used for The winding path to 270 electoral votes

forked from <a href='http://bl.ocks.org/bycoffe/'>bycoffe</a>'s block: <a href='http://bl.ocks.org/bycoffe/18441cddeb8fe147b719fab5e30b5d45'>Split an SVG path into pieces</a>

mit Licensed

Similar vizzes