Class ColorMapCSS
Coloring is a wrapper class for different schemes to map data onto colors for
2D visualizations using the HTML5
canvas element. Each inner
class implements the ColorMap interface to provide an implementation
agnostic manner to translate data into colors.
The following color mappings are currently available:
- Index
- Associates integer indices with colors.
- Gradient1D
- One dimensional color gradient spanning two or more colors.
- Hue
- Special case of
Gradient1Dwhere the gradient follows the color hue. - Gradient2D
- Two dimensional gradient with each dimension represented by one color.
- GradientND
- Multi-dimensional gradient spanned by an identical number of colors
- Author:
- Christoph Hauert
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classOne dimensional color gradient spanning two or more colorsstatic classTwo dimensional color gradient with one color for each dimension.static classNdimensional color gradient with one color for each dimension.static classColor gradient following the hue.static classAssociates integer indices with colors.Nested classes/interfaces inherited from class ColorMap
ColorMap.Gradient<T> -
Field Summary
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProtected constructor to restrict instantiation to subclasses. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringConvert Color to CSS style string.static String[]Convert an array of Color's to an array of CSS style strings.static doubleluminance(double[] color) Compute the relative luminance of the color components incolor.static doubleCompute the relative luminance ofcolor.static doubleCompute the relative luminance of the CSS color stringcolor.private static StringUtility function to add padding (if needed) of leading zero'es to ensure that each color component is encoded by a two digit hexadecimal.static StringRGB2Css(int r, int g, int b) Convert the three components of a 24bit color,r, g, andbto a CSS color style.static StringRGBA2Css(int r, int g, int b, int a) Convert the four components of a 32bit color,r, g, b, andato a CSS color style.private static doublesRGBChannel2Intensity(double value) Convert a gamma-encoded color component to linear light.Methods inherited from class ColorMap
addAlpha, addAlpha, addColors, blendColors, blendColors, color2Color, translate, translate, translate, translate, translate
-
Constructor Details
-
ColorMapCSS
protected ColorMapCSS()Protected constructor to restrict instantiation to subclasses.
-
-
Method Details
-
Color2Css
Convert Color to CSS style string. For colors with transparency, the output is of the formrgba(r, g, b, a), wherer, g, b, andarefer to the red, green, blue and alpha (transparency) components. Without transparency the output is of the form#rrggbb, whererr, gg, andbbare the hexadecimal representation of the red, green and blue components, respectively.- Parameters:
color- the color to convert- Returns:
- CSS color string
- See Also:
-
Color2Css
-
RGBA2Css
Convert the four components of a 32bit color,r, g, b, andato a CSS color style.- Parameters:
r- the red component0-255g- the green component0-255b- the blue component0-255a- the alpha (transparency) component[0,1]- Returns:
- CSS color string
rgba(r, g, b, a)
-
RGB2Css
Convert the three components of a 24bit color,r, g, andbto a CSS color style.- Parameters:
r- the red component0-255g- the green component0-255b- the blue component0-255- Returns:
- CSS color string
#rrggbb
-
luminance
Compute the relative luminance ofcolor.Colors with transparency are composited over white before computing luminance.
- Parameters:
color- the color- Returns:
- relative luminance in
[0,1]
-
luminance
Compute the relative luminance of the CSS color stringcolor.- Parameters:
color- the CSS color string- Returns:
- relative luminance in
[0,1]
-
luminance
public static double luminance(double[] color) Compute the relative luminance of the color components incolor.The array is interpreted as RGB or RGBA in
[0,255]. If an alpha channel is present it is composited over white before computing luminance.- Parameters:
color- the RGB or RGBA channels- Returns:
- relative luminance in
[0,1]
-
pad
-
sRGBChannel2Intensity
private static double sRGBChannel2Intensity(double value) Convert a gamma-encoded color component to linear light.- Parameters:
value- the channel value in[0,1]- Returns:
- linearized channel value
-