Provides color gradient manipulation API that is extensible via plugins.

Constructors

Properties

_colors: Color[] = []

The list of colors that comprise the gradient.

_componentValues: number[][] = []

Component values grouped by channel.

_domain: number[] = []

The stop values for each color.

_interpolatedVersion?: number

The version of the gradient that was interpolated during the last getComponents call.

_interpolatorFactory?: InterpolatorFactory

The interpolation factory that was used during the last getComponents call.

_interpolators: Interpolator[] = []

Color component interpolators that were produced by _interpolatorFactory for components provided by the _model for colors with cumulative version _interpolatedVersion.

_model?: ColorModel

The model that was requested during the last getComponents call.

_tempComponents: number[] = ...

Color components returned by the getComponents method.

Accessors

  • get version(): number
  • The integer value that is incremented when an underlying color is changed.

    Returns number

Methods

  • Returns the color at the given position in the gradient.

    Parameters

    • x: number

      The value from the gradient domain for which the color is requested.

    • Optionalmodel: ColorModel = RGB

      The color model that should be used for interpolation.

    • OptionalinterpolatorFactory: InterpolatorFactory = lerp

      The function that returns a color component interpolator.

    Returns Color

    The new Color instance.

  • Returns color components that correspond to a value from the gradient domain.

    Note: Don't keep reference to the returned array because it is reused between getComponents invocations.

    Parameters

    • model: ColorModel

      The color model that provides the components for interpolation.

    • value: number

      The domain value.

    • interpolatorFactory: InterpolatorFactory

      The function that returns an interpolator. If the same function identity is provided on each call, interpolation result is cached for better performance.

    Returns readonly number[]

    The read-only components array.

  • Adds the new stop to the gradient.

    Parameters

    • value: number

      The position of the stop.

    • color: ColorLike

      The color associated with the stop.

    Returns Gradient