Class ColorScale
java.lang.Object
com.codename1.ui.chart.ColorScale
Maps numbers to colours for heatmaps: a sequence of colour stops interpolated linearly.
ColorScale temp = ColorScale.diverging(0x2166AC, 0xF7F7F7, 0xB2182B);
int rgb = temp.colorAt(0.75);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcolorAt(double f) The colour at a position.static ColorScalediverging(int low, int mid, int high) A two hue scale through a neutral middle, for values above and below a reference.static ColorScalesequential(int rgb) A single hue scale from a pale tint to the full colour, for magnitudes.static ColorScaleviridis()A perceptually uniform scale (viridis) that stays readable in greyscale and for colour-blind readers.
-
Constructor Details
-
ColorScale
public ColorScale(double[] positions, int[] colors) Creates a scale from stops.
Parameters
-
positions: ascending stop positions from 0 to 1 -
colors: the colour at each stop
-
-
-
Method Details
-
sequential
A single hue scale from a pale tint to the full colour, for magnitudes.
Parameters
rgb: the colour of the largest values
Returns
the scale
-
diverging
A two hue scale through a neutral middle, for values above and below a reference.
Parameters
-
low: the colour of the smallest values -
mid: the neutral middle colour -
high: the colour of the largest values
Returns
the scale
-
-
viridis
A perceptually uniform scale (viridis) that stays readable in greyscale and for colour-blind readers.
Returns
the scale
-
colorAt
public int colorAt(double f) The colour at a position.
Parameters
f: 0 to 1; values outside are clamped
Returns
an RGB colour
-