Skip to main content

normalizePath()

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"
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
normalizePath("remotion"); // Error: Malformed path data: ...
tsx
normalizePath("remotion"); // Error: Malformed path data: ...

Credits

Source code stems mostly from svg-path-reverse.

See also