A less-sophisticated alternative to Mike Bostock’s Gradient Along Stroke.
Note that this version does not compute mitre joints, so sharp bends reveal the segmented nature of the “path.”