A toolkit for working with phylogenetic data.
v0.20.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ColorMap Class Reference

#include <genesis/utils/tools/color/map.hpp>

Detailed Description

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.

Public Member Functions

 ColorMap ()=default
 
 ColorMap (std::vector< Color > const &colors)
 
 ColorMap (ColorMap const &)=default
 
 ColorMap (ColorMap &&)=default
 
 ~ColorMap ()=default
 
ColorMapclip (bool value)
 
bool clip_over () const
 Clip (clamp) values greater than max() to be inside [ min, max ]. More...
 
ColorMapclip_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...
 
ColorMapclip_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< Colorcolor_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 mask_color () const
 Color that indicates values equal to mask_value() or non-finite values. More...
 
ColorMapmask_color (Color value)
 Color that indicates values equal to mask_value() or non-finite values. 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...
 
std::vector< Coloroperator() (std::vector< double > const &values) const
 Return the mapped colors for a vector of values. More...
 
template<class ForwardIterator >
std::vector< Coloroperator() (ForwardIterator first, ForwardIterator last) const
 Return the mapped colors for a range of values. More...
 
Color operator() (ColorNormalization const &norm, double value) const
 Return a Color for the given value, normalized by norm. More...
 
std::vector< Coloroperator() (ColorNormalization const &norm, std::vector< double > const &values) const
 Return the mapped colors for a vector of values, normalized by norm. More...
 
template<class ForwardIterator >
std::vector< Coloroperator() (ColorNormalization const &norm, ForwardIterator first, ForwardIterator last) const
 Return the mapped colors for a range of values, normalized by norm. More...
 
ColorMapoperator= (ColorMap const &)=default
 
ColorMapoperator= (ColorMap &&)=default
 
Color over_color () const
 Color that indicates values greater than max(). More...
 
ColorMapover_color (Color value)
 Color that indicates values greater than max(). More...
 
ColorMappalette (std::vector< Color > const &value)
 
std::vector< Color > const & palette () const
 Get the color list currently in use. More...
 
bool reverse () const
 Use the palette colors in reverse, back to front. More...
 
ColorMapreverse (bool value)
 
size_t size () const
 Return the size of the map, that is, the number of colors in the list. More...
 
Color under_color () const
 Color that indicates values less than min(). More...
 
ColorMapunder_color (Color value)
 Color that indicates values less than min(). More...
 

Constructor & Destructor Documentation

ColorMap ( )
default
ColorMap ( std::vector< Color > const &  colors)
inline

Definition at line 71 of file map.hpp.

~ColorMap ( )
default
ColorMap ( ColorMap const &  )
default
ColorMap ( ColorMap &&  )
default

Member Function Documentation

ColorMap& clip ( bool  value)
inline

Set both clip_under( bool ) and clip_over( bool ).

Definition at line 178 of file map.hpp.

bool clip_over ( ) const
inline

Clip (clamp) values greater than max() to be inside [ min, max ].

If set to true, over_color() is not used to indicate values out of range.

Definition at line 131 of file map.hpp.

ColorMap& clip_over ( bool  value)
inline

Clip (clamp) values greater than max() to be inside [ min, max ].

If set to true, over_color() is not used to indicate values out of range.

Definition at line 197 of file map.hpp.

bool clip_under ( ) const
inline

Clip (clamp) values less than min() to be inside [ min, max ].

If set to true, under_color() is not used to indicate values out of range.

Definition at line 121 of file map.hpp.

ColorMap& clip_under ( bool  value)
inline

Clip (clamp) values less than min() to be inside [ min, max ].

If set to true, under_color() is not used to indicate values out of range.

Definition at line 188 of file map.hpp.

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 249 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.

bool empty ( ) const
inline

Return whether the Palette is empty, that is, no colors were set.

Definition at line 230 of file map.hpp.

Color mask_color ( ) const
inline

Color that indicates values equal to mask_value() or non-finite values.

Definition at line 91 of file map.hpp.

ColorMap& mask_color ( Color  value)
inline

Color that indicates values equal to mask_value() or non-finite values.

Definition at line 151 of file map.hpp.

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.

std::vector< Color > operator() ( std::vector< double > const &  values) const

Return the mapped colors for a vector of values.

Simply applies operator() ( double value ) to all values.

Definition at line 125 of file map.cpp.

std::vector<Color> operator() ( ForwardIterator  first,
ForwardIterator  last 
) const
inline

Return the mapped colors for a range of values.

Simply applies operator() ( double value ) to all values.

Definition at line 297 of file map.hpp.

Color operator() ( ColorNormalization const &  norm,
double  value 
) const

Return a Color for the given value, normalized by norm.

Definition at line 131 of file map.cpp.

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.

Definition at line 136 of file map.cpp.

std::vector<Color> operator() ( ColorNormalization const &  norm,
ForwardIterator  first,
ForwardIterator  last 
) const
inline

Return the mapped colors for a range of values, normalized by norm.

Definition at line 321 of file map.hpp.

ColorMap& operator= ( ColorMap const &  )
default
ColorMap& operator= ( ColorMap &&  )
default
Color over_color ( ) const
inline

Color that indicates values greater than max().

Only used if clip_over() == false.

Definition at line 101 of file map.hpp.

ColorMap& over_color ( Color  value)
inline

Color that indicates values greater than max().

Only used if clip_over() == false.

Definition at line 160 of file map.hpp.

ColorMap& palette ( std::vector< Color > const &  value)
inline

Definition at line 209 of file map.hpp.

std::vector<Color> const& palette ( ) const
inline

Get the color list currently in use.

Definition at line 222 of file map.hpp.

bool reverse ( ) const
inline

Use the palette colors in reverse, back to front.

Definition at line 139 of file map.hpp.

ColorMap& reverse ( bool  value)
inline

Definition at line 203 of file map.hpp.

size_t size ( ) const
inline

Return the size of the map, that is, the number of colors in the list.

Definition at line 238 of file map.hpp.

Color under_color ( ) const
inline

Color that indicates values less than min().

Only used if clip_under() == false.

Definition at line 111 of file map.hpp.

ColorMap& under_color ( Color  value)
inline

Color that indicates values less than min().

Only used if clip_under() == false.

Definition at line 169 of file map.hpp.


The documentation for this class was generated from the following files: