Options
All
  • Public
  • Public/Protected
  • All
Menu

Tracks a "low" and "high" color, and interpolates between these endpoints when given a number between 0 and 1. Color is expressed as an array of either [red, green, blue] or [red, green, blue, alpha], where red, green and blue range from 0 to 255, and alpha range from 0.0 to 1.0.

Hierarchy

  • InterpolatableColor

Index

Constructors

constructor

Properties

Readonly color

color: [number, number, number, number] = ...

The current color, at point interpolation between low and high.

Readonly highColor

highColor: [number, number, number, number] = ...

The "high" color, returned when interpolation is 1

Readonly lowColor

lowColor: [number, number, number, number] = ...

The "low" color, returned when interpolation is 0

Accessors

interpolation

  • get interpolation(): number
  • set interpolation(t: number): void
  • Gets or sets the interpolation point, in turn controlling the color.

    see

    interpolate

    Returns number

  • Gets or sets the interpolation point, in turn controlling the color.

    Parameters

    • t: number

    Returns void

Methods

clone

  • Creates a copy of this color, with the same values as the current.

    Returns InterpolatableColor

interpolate

  • Sets the interpolation to a given position from 0.0 to 1.0 between the low and high color and alpha values, in turn determining the color.

    Parameters

    • t: number

    Returns InterpolatableColor

setColor

  • setColor(color: [red: number, green: number, blue: number] | [red: number, green: number, blue: number, alpha: number]): InterpolatableColor
  • Sets both low and high color to the same value.

    example

    let color = new InterpolatableColor() .setColor([255, 0, 0]) .setLowAlpha(0) .setHighAlpha(1);

    Parameters

    • color: [red: number, green: number, blue: number] | [red: number, green: number, blue: number, alpha: number]

    Returns InterpolatableColor

setHighAlpha

  • Sets the high alpha while keeping the existing color values.

    Parameters

    • a: number

    Returns InterpolatableColor

setHighColor

  • setHighColor(color: [red: number, green: number, blue: number] | [red: number, green: number, blue: number, alpha: number]): InterpolatableColor
  • Sets the high color

    Parameters

    • color: [red: number, green: number, blue: number] | [red: number, green: number, blue: number, alpha: number]

    Returns InterpolatableColor

setLowAlpha

  • Sets the low alpha while keeping the existing color values.

    Parameters

    • a: number

    Returns InterpolatableColor

setLowColor

  • setLowColor(color: [red: number, green: number, blue: number] | [red: number, green: number, blue: number, alpha: number]): InterpolatableColor
  • Sets the low color

    Parameters

    • color: [red: number, green: number, blue: number] | [red: number, green: number, blue: number, alpha: number]

    Returns InterpolatableColor