Skip to main content

getLength()

属于 @remotion/paths 软件包的一部分.

🌐 Part of the @remotion/paths package.

获取 SVG 路径的长度。参数必须是有效的 SVG 路径属性。

🌐 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:

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:

getLength("remotion"); // Error: Malformed path data: ...

鸣谢

🌐 Credits

源代码主要来源于 svg-path-properties

🌐 Source code stems mostly from svg-path-properties.

另请参阅

🌐 See also