reduceInstructions()
Part of the @remotion/paths
package. Available from v3.3.40
Takes an array of Instruction
's and reduces the amount of instruction types them so the path only consists of M
, L
, C
and Z
instructions.
note
In versions before v4.0.168, Q
instructions were reduced away.
In reverse logic, this function will eliminate all H
, V
, S
, T
, A
, Q
m
, l
, h
, v
, c
, s
, q
, t
, a
, q
and z
instructions.
This is useful if you want to manually edit a path and want to make sure it's as simple as possible.
Note that this may result in a longer path.
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
type
If you want a type which includes only reduced instructions, you can import the ReducedInstruction
type.
ts
import {ReducedInstruction } from "@remotion/paths";
ts
import {ReducedInstruction } from "@remotion/paths";