Skip to main content
100%

Point-Along-Path Interpolation

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

A click on the SVG canvas spawns a blue circle that continuously animates along a closed Catmull–Rom spline, while a second static path outlines a similar shape. The moving circle’s position is interpolated using the SVG path methods `getTotalLength` and `getPointAtLength`, driven by D3’s `transition.attrTween` over a 10-second loop. Two cardinal-closed paths are drawn with `d3.svg.line`, and the code also supports adding runners with random colors.

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>

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>

gpl-3.0 Licensed

Similar vizzes