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
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
protectedstatic_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()
staticgetColor(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
The color map interpolator to use
Returns
The RGB color
getColorArray()
staticgetColorArray(color,res?):ColorRGB[]
Defined in: colormap.ts:69
Get color array used by interpolator
Parameters
color
The color map interpolator to use
res?
number = 256
The resolution of the color map
Returns
ColorRGB[]
The array of colors
getColorMap()
staticgetColorMap(color,res?):ColorTEX
Defined in: colormap.ts:51
Get color map for a specific color map interpolator
Parameters
color
The color map interpolator to use
res?
number = 256
The resolution of the color map
Returns
The texture representation of the color map
hexToRgb()
statichexToRgb(color):ColorRGB
Defined in: colormap.ts:96
Convert HEX color to RGB format
Parameters
color
`#${string}`
The HEX color to convert
Returns
The RGB representation of the color
rgbToHex()
staticrgbToHex(color):`#${string}`
Defined in: colormap.ts:86
Convert RGB color to HEX format
Parameters
color
The RGB color to convert
Returns
`#${string}`
The HEX representation of the color