Point-Along-Path Interpolation
Two nested, closed Catmull–Rom splines define the paths in this SVG animation. Clicking anywhere adds a colored circle that first collapses to the inner path’s start, then follows the outer path via a tween that switches between the two paths partway through the animation. The code uses D3 v3’s `transition.attrTween` with the native SVG `getTotalLength` and `getPointAtLength` methods to interpolate each circle’s position, while a text element displays the tween progress as a percentage.
AI-generated descriptionThis example demonstrates how to use the getTotalLength and getPointAtLength methods on SVG path elements to interpolate a point along a Catmull–Rom spline.
A related technique is stroke dash interpolation.
forked from <a href='http://bl.ocks.org/mbostock/'>mbostock</a>'s block: <a href='http://bl.ocks.org/mbostock/1705868'>Point-Along-Path Interpolation</a>
forked from <a href='http://bl.ocks.org/antonyross/'>antonyross</a>'s block: <a href='http://bl.ocks.org/antonyross/da1e1bdb53cd9df07b0d7848835f2b9f'>Point-Along-Path Interpolation</a>
forked from <a href='http://bl.ocks.org/antonyross/'>antonyross</a>'s block: <a href='http://bl.ocks.org/antonyross/79c75e46b93860f74a7c29f3a190a8ca'>Point-Along-Path Interpolation</a>
forked from <a href='http://bl.ocks.org/antonyross/'>antonyross</a>'s block: <a href='http://bl.ocks.org/antonyross/fbc32c4d940260be137180b55ae6f428'>Point-Along-Path Interpolation</a>