Class InterpolatedVars<TUnit>

Creates a list of interpolated values from a given list of ControlVars.


const v1 = new ControlVar(Units.num, 0)
const v2 = new ControlVar(Units.num, 100)

const interpolated = new InterpolatedVars("spacing", Units.px, [v1, v2])
// interpolates from 0-100

v1.set(50) // interpolated will now update to interpolate from 50-100

It can be passed multiple stops.

const interpolated = new InterpolatedVars("spacing", Units.px, [v1, v2, v3])

... or stops with positions (otherwise they are evenly spaced).

	// positions should be in a 0-1 percentage range
const interpolated = new InterpolatedVars("spacing", Units.px, [[0, v1], [0.2, v2], [1, v3]])

You can change interpolation control variables and any options using set:

interpolated.set("values", [vOther1, vOther2, vOther3])
interpolated.set("options", {steps: 20})

Type Parameters

  • TUnit extends Record<string, any> = Record<string, any>

Hierarchy (View Summary)

  • Base
    • InterpolatedVars

Constructors

Properties

_dependants: Base[] = []
interpolated: Record<string, string> = {}
name: string
ready: boolean = false
unit: (value: TUnit) => string
value: Record<string, any>[] = []
values: Value<TUnit>

Methods

  • Parameters

    • dep: any

    Returns void