reduceInstructions()
属于@remotion/paths包。从v3.3.40版本开始可用
接受一个Instruction数组,并将指令类型减少到仅包含M、L、C和Z指令的路径。
note
在v4.0.168之前的版本中,Q指令被减少了。
按照相反的逻辑,此函数将消除所有H、V、S、T、A、Q、m、l、h、v、c、s、q、t、a、q和z指令。
如果您想手动编辑路径并确保其尽可能简单,这将非常有用。
请注意,这可能会导致路径变得更长。
tsimport {reduceInstructions ,ReducedInstruction } from "@remotion/paths";constsimplified :ReducedInstruction [] =reduceInstructions ([{type : "m",dx : 10,dy : 10 },{type : "h",dx : 100 },]);/*[{type: 'M', x: 10, y: 10},{type: 'L', x: 110, y: 10},]*/
tsimport {reduceInstructions ,ReducedInstruction } from "@remotion/paths";constsimplified :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类型。
tsimport {ReducedInstruction } from "@remotion/paths";
tsimport {ReducedInstruction } from "@remotion/paths";