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

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

Detailed Description

Definition at line 50 of file palette.hpp.

Public Member Functions

 ColorPalette ()=default
 
 ColorPalette (std::vector< Color > const &colors)
 
 ColorPalette (ColorPalette const &)=default
 
 ColorPalette (ColorPalette &&) noexcept=default
 
 ~ColorPalette ()=default
 
bool clip () const
 Clip values to be inside [ min max ]. More...
 
ColorPaletteclip (bool value)
 
Color diverging_color (double value) const
 Get a color by using the palette for a diverging scale. More...
 
std::vector< Colordiverging_colors (std::vector< double > const &values) const
 
Color mask_color () const
 Color that indicates values equal to mask_value(). More...
 
ColorPalettemask_color (Color value)
 
double mask_value () const
 Mask value that identifies invalid values. More...
 
ColorPalettemask_value (double value)
 
double max () const
 
ColorPalettemax (double value)
 
double mid () const
 
ColorPalettemid (double value)
 
double min () const
 
ColorPalettemin (double value)
 
ColorPaletteoperator= (ColorPalette const &)=default
 
ColorPaletteoperator= (ColorPalette &&) noexcept=default
 
Color over_color () const
 Color that indicates values greater than max(). More...
 
ColorPaletteover_color (Color value)
 
std::vector< Color > const & palette () const
 
ColorPalettepalette (std::vector< Color > const &value)
 
Color qualitative_color (size_t index) const
 
std::vector< Colorqualitative_colors (std::vector< size_t > const &values) const
 
ColorPaletterange (double min, double max)
 
ColorPaletterange (double min, double mid, double max)
 
template<class ForwardIterator >
void range (ForwardIterator first, ForwardIterator last)
 Set the min and max of the Palette to the min and max valid values that are found in the range [ first, last ). More...
 
bool reverse () const
 Use the palette colors in reverse, back to front. More...
 
ColorPalettereverse (bool value)
 
Color sequential_color (double value) const
 
std::vector< Colorsequential_colors (std::vector< double > const &values) const
 
Color under_color () const
 Color that indicates values less than min(). More...
 
ColorPaletteunder_color (Color value)
 

Constructor & Destructor Documentation

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

Definition at line 60 of file palette.hpp.

~ColorPalette ( )
default
ColorPalette ( ColorPalette const &  )
default
ColorPalette ( ColorPalette &&  )
defaultnoexcept

Member Function Documentation

bool clip ( ) const
inline

Clip values to be inside [ min max ].

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

Definition at line 141 of file palette.hpp.

ColorPalette& clip ( bool  value)
inline

Definition at line 255 of file palette.hpp.

Color diverging_color ( double  value) const

Get a color by using the palette for a diverging scale.

The min() and max() values determine the boundaries of the range of allowed values; they map to the first and last entry of the palette, respectively. The mid() value is used as the "neutral" value in the range of allowed values, that is, it maps to the central color of the palette.

In other words, values in [ min, mid ] are mapped to the first half of the palette, and values in [ mid, max ] to the second half:

     palette
   |----|----|
  /      \    \
 /        \    \
 |---------|---|
min      mid  max

Values outside of the allowed range [ min, max ], as well as non-finite values, are treated according to the settings clip(), mask_value(), mask_color(), under_color(), over_color().

Definition at line 90 of file palette.cpp.

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

Definition at line 131 of file palette.cpp.

Color mask_color ( ) const
inline

Color that indicates values equal to mask_value().

Definition at line 110 of file palette.hpp.

ColorPalette& mask_color ( Color  value)
inline

Definition at line 237 of file palette.hpp.

double mask_value ( ) const
inline

Mask value that identifies invalid values.

When querying a value that compares equal to the mask value, the color functions return mask_color() instead of a Color from the palette. This is meant as a simple means of filtering and visualizing invalid values.

The mask value is initialized to quiet NaN, so that it never compares equal to anything. Thus, it is not used by default has to be explicitly set to a different value.

Definition at line 102 of file palette.hpp.

ColorPalette& mask_value ( double  value)
inline

Definition at line 231 of file palette.hpp.

double max ( ) const
inline

Definition at line 87 of file palette.hpp.

ColorPalette& max ( double  value)
inline

Definition at line 225 of file palette.hpp.

double mid ( ) const
inline

Definition at line 82 of file palette.hpp.

ColorPalette& mid ( double  value)
inline

Definition at line 219 of file palette.hpp.

double min ( ) const
inline

Definition at line 77 of file palette.hpp.

ColorPalette& min ( double  value)
inline

Definition at line 213 of file palette.hpp.

ColorPalette& operator= ( ColorPalette const &  )
default
ColorPalette& operator= ( ColorPalette &&  )
defaultnoexcept
Color over_color ( ) const
inline

Color that indicates values greater than max().

Only used if clip() == false.

Definition at line 120 of file palette.hpp.

ColorPalette& over_color ( Color  value)
inline

Definition at line 243 of file palette.hpp.

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

Definition at line 154 of file palette.hpp.

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

Definition at line 267 of file palette.hpp.

Color qualitative_color ( size_t  index) const

Definition at line 67 of file palette.cpp.

std::vector< Color > qualitative_colors ( std::vector< size_t > const &  values) const

Definition at line 113 of file palette.cpp.

ColorPalette & range ( double  min,
double  max 
)

Definition at line 47 of file palette.cpp.

ColorPalette & range ( double  min,
double  mid,
double  max 
)

Definition at line 55 of file palette.cpp.

void range ( ForwardIterator  first,
ForwardIterator  last 
)
inline

Set the min and max of the Palette to the min and max valid values that are found in the range [ first, last ).

Furthermore, mid is set to the average of the values.

The provided iterator range needs to contain values that are convertible and comparable to double. Any non-finite values or values that are equal to the mask_value() are skipped.

Definition at line 177 of file palette.hpp.

bool reverse ( ) const
inline

Use the palette colors in reverse, back to front.

Definition at line 149 of file palette.hpp.

ColorPalette& reverse ( bool  value)
inline

Definition at line 261 of file palette.hpp.

Color sequential_color ( double  value) const

Definition at line 75 of file palette.cpp.

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

Definition at line 122 of file palette.cpp.

Color under_color ( ) const
inline

Color that indicates values less than min().

Only used if clip() == false.

Definition at line 130 of file palette.hpp.

ColorPalette& under_color ( Color  value)
inline

Definition at line 249 of file palette.hpp.


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