Skip to main content

reversePath()

Part of the @remotion/paths package.

Reverses a path so the end and start are switched.

tsx
import { getLength } from "@remotion/paths";
 
const reversedPath = getLength("M 0 0 L 100 0");
console.log(reversedPath); // "L 100 0 M 0 0"
tsx
import { getLength } from "@remotion/paths";
 
const reversedPath = getLength("M 0 0 L 100 0");
console.log(reversedPath); // "L 100 0 M 0 0"

The function will throw if the path is invalid:

tsx
getLength("remotion"); // Error: Malformed path data: ...
tsx
getLength("remotion"); // Error: Malformed path data: ...

Credits

Source code stems mostly from svg-path-reverse.

See also