Skip to main content

reduceInstructions()

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

接受一个Instruction数组,并将指令类型减少到仅包含MLCZ指令的路径。

note

在v4.0.168之前的版本中,Q指令被减少了。

按照相反的逻辑,此函数将消除所有HVSTAQmlhvcsqtaqz指令。

如果您想手动编辑路径并确保其尽可能简单,这将非常有用。

请注意,这可能会导致路径变得更长。

ts
import { reduceInstructions, ReducedInstruction } from "@remotion/paths";
 
const simplified: ReducedInstruction[] = reduceInstructions([
{ type: "m", dx: 10, dy: 10 },
{ type: "h", dx: 100 },
]);
 
/*
[
{type: 'M', x: 10, y: 10},
{type: 'L', x: 110, y: 10},
]
*/
ts
import { reduceInstructions, ReducedInstruction } from "@remotion/paths";
 
const simplified: ReducedInstruction[] = reduceInstructions([
{ type: "m", dx: 10, dy: 10 },
{ type: "h", dx: 100 },
]);
 
/*
[
{type: 'M', x: 10, y: 10},
{type: 'L', x: 110, y: 10},
]
*/

ReducedInstruction 类型

如果您想要一个仅包含减少指令的类型,可以导入ReducedInstruction类型。

ts
import { ReducedInstruction } from "@remotion/paths";
ts
import { ReducedInstruction } from "@remotion/paths";

另请参阅