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
指令。
如果您想手动编辑路径并确保其尽可能简单,这将非常有用。
请注意,这可能会导致路径变得更长。
ts
import {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},]*/
ts
import {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
类型。
ts
import {ReducedInstruction } from "@remotion/paths";
ts
import {ReducedInstruction } from "@remotion/paths";