Back to Remotion

normalizePath()

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

4.0.471902 B
Original Source

Part of the @remotion/paths package.

Removes all relative coordinates from a path and converts them into absolute coordinates.

Returns a string if the path is valid:

tsx
import { normalizePath } from "@remotion/paths";

const normalizedPath = normalizePath("M 50 50 l 100 0");
console.log(normalizedPath); // "M 50 50 L 150 50"

The function will throw if the path is invalid:

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

Credits

Source code stems mostly from svg-path-reverse.

See also