Skip to main content

serializeInstructions()

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

接受一个Instruction数组,并将其序列化为SVG路径字符串。

serialize-instructions.ts
tsx
import { serializeInstructions } from "@remotion/paths";
 
const newPath = serializeInstructions([
{
type: "M",
x: 10,
y: 10,
},
{
type: "L",
x: 20,
y: 20,
},
]); // M 10 10 L 20 20
serialize-instructions.ts
tsx
import { serializeInstructions } from "@remotion/paths";
 
const newPath = serializeInstructions([
{
type: "M",
x: 10,
y: 10,
},
{
type: "L",
x: 20,
y: 20,
},
]); // M 10 10 L 20 20

如果指令与Instruction类型不匹配,此函数可能会抛出异常,但它不会明确检查无效输入。

另请参阅