color.h File Reference
#include <cmath>
#include <cstdlib>
+ Include dependency graph for color.h:

Go to the source code of this file.

Namespaces

namespace  ColorMap
 

Typedefs

typedef uint32_t Color
 RGBA color.
 

Enumerations

enum  Value { JET , SUMMER , AUTUMN , COOL }
 Color maps that associate a color to every float from [0..1]. More...
 

Functions

template<typename T>
const Tclamp (const T &value, const T &low, const T &high)
 
Color generateRandomColor ()
 Generate a random 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 getColorFromRGB (float r, float g, float b)
 Get a color from R, G, and B values (floats).
 
Color getColorFromRGB (uint8_t r, uint8_t g, uint8_t b)
 Get a color from R, G, and B values (chars).
 
void getRGBFromColor (Color color, uint8_t *rgb)
 Get R, G, and B values (chars) as array from a color.
 

Typedef Documentation

◆ Color

typedef uint32_t Color

RGBA color.

Definition at line 8 of file color.h.

Function Documentation

◆ clamp()

template<typename T>
const T & clamp ( const T & value,
const T & low,
const T & high )

Definition at line 33 of file color.h.

+ Here is the caller graph for this function:

◆ generateRandomColor()

Color generateRandomColor ( )

Generate a random color.

Definition at line 69 of file color.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColor()

Color getColor ( float value,
ColorMap::Value colormap = ColorMap::JET )

Get the color for a given number in [0..1] using a given colormap.

Input values that are outside of the [0..1] region are clamped automatically.

See also
ColorMap

Definition at line 84 of file color.h.

+ Here is the call graph for this function:

◆ getColorFromRGB() [1/2]

Color getColorFromRGB ( float r,
float g,
float b )

Get a color from R, G, and B values (floats).

The input values are mapped from [0..1] to [0..255]. Input value that are outside of the [0..1] region are clamped automatically.

Definition at line 51 of file color.h.

+ Here is the call graph for this function:

◆ getColorFromRGB() [2/2]

Color getColorFromRGB ( uint8_t r,
uint8_t g,
uint8_t b )

Get a color from R, G, and B values (chars).

Definition at line 40 of file color.h.

+ Here is the caller graph for this function:

◆ getRGBFromColor()

void getRGBFromColor ( Color color,
uint8_t * rgb )

Get R, G, and B values (chars) as array from a color.

Definition at line 60 of file color.h.