Skip to content

autk-map


autk-map / ColorMap

Class: ColorMap

Defined in: colormap.ts:15

ColorMap class provides methods to handle color mapping and interpolation. It allows retrieval of colors based on values and color map interpolators, as well as conversion between RGB and HEX color formats.

Example

ts
const color = ColorMap.getColor(0.5, ColorMapInterpolator.SEQUENTIAL_REDS);
const colorMap = ColorMap.getColorMap(ColorMapInterpolator.SEQUENTIAL_REDS, 256);

Constructors

Constructor

new ColorMap(): ColorMap

Returns

ColorMap

Properties

_interpolator

protected static _interpolator: (t) => string

Defined in: colormap.ts:20

The color map interpolator function. This is set when a color map is requested.

Parameters

t

number

Returns

string

Methods

getColor()

static getColor(value, color): ColorRGB

Defined in: colormap.ts:31

ColorMap class provides methods to handle color mapping and interpolation.

It allows retrieval of colors based on values and color map interpolators, as well as conversion between RGB and HEX color formats.

Parameters

value

number

The value to get the color for

color

ColorMapInterpolator

The color map interpolator to use

Returns

ColorRGB

The RGB color


getColorArray()

static getColorArray(color, res?): ColorRGB[]

Defined in: colormap.ts:69

Get color array used by interpolator

Parameters

color

ColorMapInterpolator

The color map interpolator to use

res?

number = 256

The resolution of the color map

Returns

ColorRGB[]

The array of colors


getColorMap()

static getColorMap(color, res?): ColorTEX

Defined in: colormap.ts:51

Get color map for a specific color map interpolator

Parameters

color

ColorMapInterpolator

The color map interpolator to use

res?

number = 256

The resolution of the color map

Returns

ColorTEX

The texture representation of the color map


hexToRgb()

static hexToRgb(color): ColorRGB

Defined in: colormap.ts:96

Convert HEX color to RGB format

Parameters

color

`#${string}`

The HEX color to convert

Returns

ColorRGB

The RGB representation of the color


rgbToHex()

static rgbToHex(color): `#${string}`

Defined in: colormap.ts:86

Convert RGB color to HEX format

Parameters

color

ColorRGB

The RGB color to convert

Returns

`#${string}`

The HEX representation of the color

Released under the MIT License.