Skip to main content
100%

Point-Along-Path Interpolation

✓ Published0🌍 Public
Aantonyross
Last edited Apr 17, 2016
Created on Apr 17, 2016

Two closed Catmull–Rom splines form two nested loops, and clicking anywhere on the SVG adds a circle that animates along the outer path. The example demonstrates SVG’s `getTotalLength` and `getPointAtLength` methods to compute positions along the path, driving each circle’s transform via a `transition.attrTween` that loops indefinitely. The code uses D3 v3, with `d3.svg.line` and a cardinal-closed interpolation to define the splines, and renders the animation as SVG circles and paths.

AI-generated description

This 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>

gpl-3.0 Licensed

Similar vizzes