Works on this device
Motion Path Generator
Turn a list of points into a smooth motion path, or paste an SVG path. The tool measures its length, finds points at equal distance along it, can run it the other way, and writes the code for CSS offset-path and SVG animateMotion.
Enter your values
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Fill in the values, then choose Make the path.
Your result
How it was worked out
How to use this tool
- Choose Path through your points to type or paste points, or Length and points of an SVG path to paste the d attribute of a path.
- For points, choose a smooth curve or straight lines, and tick Close the path for a loop. You can paste points as 10,20 30,40.
- Choose how many points at equal distance you want, and the time for one trip along the path.
- Choose Make the path. Copy the path data, the CSS or the SVG file, or download them. Choose Play under the drawing to see a dot move along the path.
How it is worked out
- Smooth curve: a uniform Catmull–Rom spline passes through every point. Each piece from P(i) to P(i+1) is written as a cubic Bézier curve with the control points P(i) + (P(i+1) − P(i−1)) ÷ 6 and P(i+1) − (P(i+2) − P(i)) ÷ 6.
- Length: straight pieces are measured exactly. For a curve, the length is the integral of its speed |B′(t)| from t = 0 to 1, worked out with 16-point Gauss–Legendre quadrature on 16 equal parts of t.
- Points at equal distance: the path length is split into equal parts, and the tool finds the point at each distance with Newton's method on the same quadrature (to 1e-10 of the length). Direction is the angle of the path there: 0° points right and 90° points down.
- Running the other way keeps the same shape and starts at the other end. For a closed path the start stays where it was.
- SVG path data can use the commands M, L, H, V, C, S, Q, T and Z, absolute or relative. Quadratic pieces are written as the cubic pieces with exactly the same shape.
Worked example
The straight path M 0 0 H 100 V 100 H 0 Z is a square with sides of 100, so its length is 400. With 5 points at equal distance, the points are the four corners and the start again: (0, 0), (100, 0), (100, 100), (0, 100) and (0, 0), with directions 0°, 90°, 180°, −90° and −90° (−90° is the same as 270°: up).
Through the points (0, 0), (100, 0) and (200, 0) the smooth curve is a straight line of length 200: the control points of the first piece are (100 ÷ 6, 0) = (16.67, 0) and (100 − 200 ÷ 6, 0) = (66.67, 0).
Limits you should know
- Arc commands (A) in path data are not read. Change arcs to curves in your drawing program first.
- Points are typed or pasted; they cannot be dragged on the drawing.
- The code rounds coordinates to the decimals you choose. The length and the points use the unrounded path.
- Browsers measure paths with their own methods, so their lengths can differ from these in the last digits.
- For a Bézier path you want to draw and edit by hand, use the Bezier Path Editor. For easing along the path use the Easing Function Visualizer.