33clamp(
const T& value,
const T& low,
const T& high)
35 return (value < low ? low : (value > high ? high : value));
42 return static_cast<uint32_t
>(r) << 16 |
static_cast<uint32_t
>(g) << 8 |
43 static_cast<uint32_t
>(b);
54 static_cast<uint8_t
>(round(
clamp(g, 0.0f, 1.0f) * 255)),
55 static_cast<uint8_t
>(round(
clamp(b, 0.0f, 1.0f) * 255)));
62 rgb[0] = (color >> 16) & 0xFF;
63 rgb[1] = (color >> 8) & 0xFF;
64 rgb[2] = (color >> 0) & 0xFF;
71 uint8_t r =
static_cast<uint8_t
>((rand() % 256));
72 uint8_t g =
static_cast<uint8_t
>((rand() % 256));
73 uint8_t b =
static_cast<uint8_t
>((rand() % 256));
86 float v =
clamp(value, 0.0f, 1.0f);
91 float four_value = v * 4;
92 float r = std::min(four_value - 1.5, -four_value + 4.5);
93 float g = std::min(four_value - 0.5, -four_value + 3.5);
94 float b = std::min(four_value + 0.5, -four_value + 2.5);
uint32_t Color
RGBA color.
Color getColor(float value, ColorMap::Value colormap=ColorMap::JET)
Get the color for a given number in [0..1] using a given colormap.
Color generateRandomColor()
Generate a random color.
Color getColorFromRGB(uint8_t r, uint8_t g, uint8_t b)
Get a color from R, G, and B values (chars).
const T & clamp(const T &value, const T &low, const T &high)
void getRGBFromColor(Color color, uint8_t *rgb)
Get R, G, and B values (chars) as array from a color.
Value
Color maps that associate a color to every float from [0..1].
@ COOL
Consists of colors that are shades of cyan and magenta.
@ JET
Ranges from blue to red, and passes through the colors cyan, yellow, and orange.
@ AUTUMN
Varies smoothly from red, through orange, to yellow.
@ SUMMER
Consists of colors that are shades of green and yellow.
This file was automatically created with "create_c++_header.sh".