Back to Remotion

reversePath()

packages/docs/docs/paths/reverse-path.mdx

4.0.467744 B
Original Source

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"

The function will throw if the path is invalid:

tsx
import { reversePath } from "@remotion/paths";
// ---cut---
reversePath("remotion"); // Error: Malformed path data: ...

Credits

Source code stems mostly from svg-path-reverse.

See also