Skip to main content

getSubpaths()

属于@remotion/paths包。从v3.3.6版本开始可用

接受一个SVG路径并返回一个子路径数组。

路径中的每个Mm语句都会创建一个新的子路径。

具有两条直线的路径示例:

tsx
import { getSubpaths } from "@remotion/paths";
 
const parts = getSubpaths(`
M 0 0 L 100 0
M 0 100 L 200 100
`);
tsx
import { getSubpaths } from "@remotion/paths";
 
const parts = getSubpaths(`
M 0 0 L 100 0
M 0 100 L 200 100
`);

返回一个包含两部分的数组。

tsx
console.log(parts[0]); // "M 0 0 L 100 0"
console.log(parts[1]); // "M 0 100 L 200 100"
tsx
console.log(parts[0]); // "M 0 0 L 100 0"
console.log(parts[1]); // "M 0 100 L 200 100"

包含相对m元素的路径将被转换为M元素。

另请参阅