scoop
0.1.4
Scoop - Simple ColoR pAleTtes and mappERs
|
Class for sequential color mapppers. More...
#include <SequentialColorMap.h>
Public Types | |
enum | ColorInterpolation { RGB_INTERPOLATION = 0, HSV_INTERPOLATION } |
Types of interpolation supported. | |
Public Member Functions | |
SequentialColorMap (float minValue_=0.f, const Color &minColor=Color(0, 0, 0), float maxValue_=1.f, const Color &maxColor=Color(255, 255, 255)) | |
Default constructor. More... | |
SequentialColorMap (const std::vector< float > &values, const ColorPalette &palette) | |
Constructs a sequential color mapper based on a container of values and a color palette. More... | |
SequentialColorMap (const ColorPalette &palette, float minValue=0.f, float maxValue=1.f) | |
Constructs a sequential color mapper based on a min and max values and a color palette. More... | |
void | setFromPalette (const std::vector< float > &values, const ColorPalette &palette) |
Sets the sequential color mapper based on a container of values and a color palette. More... | |
float | minValue (void) const |
Returns the minimum key value. More... | |
float | maxValue (void) const |
Returns the maximum key value. More... | |
void | addColor (const float value, const Color &color) |
Adds a new key value and its associated color. More... | |
Color | getColor (const float value, const ColorInterpolation interpolation=RGB_INTERPOLATION) const |
Gets the color associated to a value. More... | |
Protected Attributes | |
std::map< float, Color > | _valuesToColors |
Ordered container with the mapping between values and colors. | |
Class for sequential color mapppers.
This class allows to define a sequential color mapper. It allows to define a set of key values (floats) associated to colors. It also provides methods to get a color in between key values and obtain the interpolated color, both in RGB and HSV space. In order to be created at least two key points and two colors have to be defined, otherwise it will use 0.0f and 1.0f as key values and black and white as theis associated colors.
Definition at line 43 of file SequentialColorMap.h.
scoop::SequentialColorMap::SequentialColorMap | ( | float | minValue_ = 0.f , |
const Color & | minColor = Color(0, 0, 0) , |
||
float | maxValue_ = 1.f , |
||
const Color & | maxColor = Color(255, 255, 255) |
||
) |
Default constructor.
[in] | minValue_ | minimum key value |
[in] | minColor | color associated to maximum key value |
[in] | maxValue_ | maximum key value |
[in] | maxColor | color associated to maximum key value |
scoop::SequentialColorMap::SequentialColorMap | ( | const std::vector< float > & | values, |
const ColorPalette & | palette | ||
) |
Constructs a sequential color mapper based on a container of values and a color palette.
The size of the container of values and the palette have to be the same and at least 2, otherwise an exception will be raised.
[in] | values | container of values |
[in] | palette | palette to be used |
scoop::SequentialColorMap::SequentialColorMap | ( | const ColorPalette & | palette, |
float | minValue = 0.f , |
||
float | maxValue = 1.f |
||
) |
Constructs a sequential color mapper based on a min and max values and a color palette.
A set of key values, of the size of the palette, will ba created equally distributed in the range [minValue_,maxValue_]
[in] | palette | palette to be used |
[in] | minValue | minimum key value |
[in] | maxValue | maximum key value |
void scoop::SequentialColorMap::addColor | ( | const float | value, |
const Color & | color | ||
) |
Adds a new key value and its associated color.
If key valye exists the color will be overwritten
[in] | value | new key value |
[in] | color | color to be assoaciated to the key value |
Color scoop::SequentialColorMap::getColor | ( | const float | value, |
const ColorInterpolation | interpolation = RGB_INTERPOLATION |
||
) | const |
Gets the color associated to a value.
If the value has not been registered with a color then the color returned will be interpolated in RGB os HSV color space.
[in] | value | value to query its color |
[in] | interpolation | space in which the interpolation, if needed, will be carried out |
float scoop::SequentialColorMap::maxValue | ( | void | ) | const |
Returns the maximum key value.
float scoop::SequentialColorMap::minValue | ( | void | ) | const |
Returns the minimum key value.
void scoop::SequentialColorMap::setFromPalette | ( | const std::vector< float > & | values, |
const ColorPalette & | palette | ||
) |
Sets the sequential color mapper based on a container of values and a color palette.
The size of the container of values and the palette have to be the same and at least 2, otherwise an exception will be raised. Current key values and colors are cleared.
[in] | values | container of values |
[in] | palette | palette to be used |