Point-Along-Path Interpolation
Two closed Catmull–Rom spline paths appear as black outlines on a white SVG canvas. Clicking anywhere on the canvas spawns a colored circle that animates along the path, moving at a constant speed. This is achieved by leveraging the SVG path methods `getTotalLength()` and `getPointAtLength()` to compute the circle’s position at each animation frame. The motion loops continuously, with each circle retaining its own velocity, acceleration, and top-speed properties, producing an organic, independent movement around the spline.
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>
forked from <a href='http://bl.ocks.org/antonyross/'>antonyross</a>'s block: <a href='http://bl.ocks.org/antonyross/77dff069d00125150b9dc73935e45c8c'>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/407b6f72887521cf504558b58d7300dd'>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/eb3fbb64145811ee8770436fdcea10c5'>Point-Along-Path Interpolation</a>