Skip to main content

reversePath()

Part of the @remotion/paths package.

Reverses a path so the end and start are switched.

tsx
import { reversePath } from "@remotion/paths";
 
const reversedPath = reversePath("M 0 0 L 100 0");
console.log(reversedPath); // "L 100 0 M 0 0"
tsx
import { reversePath } from "@remotion/paths";
 
const reversedPath = reversePath("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
reversePath("remotion"); // Error: Malformed path data: ...
tsx
reversePath("remotion"); // Error: Malformed path data: ...

Credits

Source code stems mostly from svg-path-reverse.

See also