Store a list of colors and offer them as a map for values in range [ 0.0, 1.0 ]
.
The class is an abstraction of color lists, making them easier to use for ranges, gradients, etc. When invoked, it interpolates between entries of the list according to the provided value. It is best used in combination with a ColorNormalization, so that arbitrary ranges can be mapped into the allowed interval [ 0.0, 1.0 ]
.
Definition at line 61 of file map.hpp.
|
| ColorMap ()=default |
|
| ColorMap (ColorMap &&)=default |
|
| ColorMap (ColorMap const &)=default |
|
| ColorMap (std::vector< Color > const &colors) |
|
| ~ColorMap ()=default |
|
ColorMap & | clip (bool value) |
|
bool | clip_over () const |
| Clip (clamp) values greater than max() to be inside [ min, max ] . More...
|
|
ColorMap & | clip_over (bool value) |
| Clip (clamp) values greater than max() to be inside [ min, max ] . More...
|
|
bool | clip_under () const |
| Clip (clamp) values less than min() to be inside [ min, max ] . More...
|
|
ColorMap & | clip_under (bool value) |
| Clip (clamp) values less than min() to be inside [ min, max ] . More...
|
|
Color | color (size_t index) const |
| Return a particular color from the palette, module the palette size. More...
|
|
std::vector< Color > | color_list (size_t n=256) const |
| Get a color list based on the palette, containing n colors sampled at equal distance across the palette. More...
|
|
bool | empty () const |
| Return whether the Palette is empty, that is, no colors were set. More...
|
|
Color const & | mask_color () const |
| Color that indicates values equal to ColorNormalization::mask_value() or non-finite values. More...
|
|
ColorMap & | mask_color (Color value) |
| Color that indicates values equal to ColorNormalization::mask_value() or non-finite values. More...
|
|
Color | operator() (ColorNormalization const &norm, double value) const |
| Return a Color for the given value , normalized by norm . More...
|
|
template<class ForwardIterator > |
std::vector< Color > | operator() (ColorNormalization const &norm, ForwardIterator first, ForwardIterator last) const |
| Return the mapped colors for a range of values, normalized by norm . More...
|
|
std::vector< Color > | operator() (ColorNormalization const &norm, std::vector< double > const &values) const |
| Return the mapped colors for a vector of values , normalized by norm . More...
|
|
Color | operator() (double value) const |
| Return an interpolated color for a value in the range [ 0.0, 1.0 ] , representing a position in the palette. More...
|
|
template<class ForwardIterator > |
std::vector< Color > | operator() (ForwardIterator first, ForwardIterator last) const |
| Return the mapped colors for a range of values. More...
|
|
std::vector< Color > | operator() (std::vector< double > const &values) const |
| Return the mapped colors for a vector of values . More...
|
|
ColorMap & | operator= (ColorMap &&)=default |
|
ColorMap & | operator= (ColorMap const &)=default |
|
Color const & | over_color () const |
| Color that indicates values greater than max(). More...
|
|
ColorMap & | over_color (Color value) |
| Color that indicates values greater than max(). More...
|
|
std::vector< Color > const & | palette () const |
| Get the color list currently in use. More...
|
|
ColorMap & | palette (std::vector< Color > const &value) |
|
bool | reverse () const |
| Use the palette colors in reverse, back to front. More...
|
|
ColorMap & | reverse (bool value) |
|
size_t | size () const |
| Return the size of the map, that is, the number of colors in the list. More...
|
|
Color const & | under_color () const |
| Color that indicates values less than min(). More...
|
|
ColorMap & | under_color (Color value) |
| Color that indicates values less than min(). More...
|
|
Color color |
( |
size_t |
index | ) |
const |
|
inline |
Return a particular color from the palette, module the palette size.
This is useful for qualitative measures. The function respects the reverse() setting, and uses modulo for indices out of range, that is, it "wraps around".
Definition at line 259 of file map.hpp.
std::vector< Color > color_list |
( |
size_t |
n = 256 | ) |
const |
Get a color list based on the palette, containing n
colors sampled at equal distance across the palette.
This is for example useful for creating a palette to write a bitmap file, see BmpWriter::to_file().
If n == 0
, the original palette is returned, making it equal to palette(). If n == 1
, the mid point color is returned.
Definition at line 47 of file map.cpp.
Color const& mask_color |
( |
| ) |
const |
|
inline |
Color operator() |
( |
double |
value | ) |
const |
Return an interpolated color for a value
in the range [ 0.0, 1.0 ]
, representing a position in the palette.
Values less than 0.0
are mapped to under_color() or to the first color of the map, depending on whether clip_under() is set. The same applies for values greater than 1.0
: Either they map to over_color() or the last color in the map, depending on whether clip_over() is set. Lastly, any non-finite values (e.g., NaN) are mapped to mask_color().
Definition at line 68 of file map.cpp.