Back to Remotion

getLength()

packages/docs/docs/paths/get-length.mdx

4.0.465903 B
Original Source

Part of the @remotion/paths package.

Gets the length of an SVG path. The argument must be a valid SVG path property.

A number is returned if the path is valid:

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

const length = getLength("M 0 0 L 100 0");
console.log(length); // 100

The function will throw if the path is invalid:

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

Credits

Source code stems mostly from svg-path-properties.

See also