Class ControlVar<TVal, TUnit>

Creates a control variable.

const controlVar = new ControlVar(Units.rgb, { r: 0, g: 0, b: 0 })

The type of the control is taken from the type of the unit formatting function.

All control variables are objects internally, but for ease of use, control variables can also be defined like:

const controlVar = new ControlVar(Units.num, 0)
// same as
const controlVar = new ControlVar(Units.num, { _: 0 })

To change their value, the set method must be used to ensure that any other variables depending on it are updated.

Type Parameters

  • TVal extends Record<string, any> | string | number | boolean = Record<string, any> | string | number | boolean

  • TUnit extends TVal extends Record<string, any>
        ? TVal
        : Record<"_", MakePrimitive<TVal>> = TVal extends Record<string, any>
        ? TVal
        : Record<"_", MakePrimitive<TVal>>

Hierarchy

Constructors

  • Type Parameters

    • TVal extends string | number | boolean | Record<string, any> = string | number | boolean | Record<string, any>

    • TUnit extends Record<string, any> | Record<"_", string> | Record<"_", number> | Record<"_", boolean> = TVal extends Record<string, any>
          ? TVal
          : Record<"_", MakePrimitive<TVal>>

    Parameters

    • unit: ((value) => string)
        • (value): string
        • Parameters

          • value: TUnit

          Returns string

    • value: TVal

    Returns ControlVar<TVal, TUnit>

Properties

_dependants: Base[] = []
css: string = ""
unit: ((value) => string)

Type declaration

    • (value): string
    • Parameters

      • value: TUnit

      Returns string

value: TUnit

Methods

  • Parameters

    • dep: any

    Returns void

  • Parameters

    • value: MakePrimitive<TVal> | TUnit

    Returns void

Generated using TypeDoc