|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_UTILS_COLOR_MAP_H_
2 #define GENESIS_UTILS_COLOR_MAP_H_
47 class ColorNormalization;
71 explicit ColorMap( std::vector<Color>
const& colors )
181 under_color_ = value;
242 return palette_.empty();
250 return palette_.size();
261 if( palette_.size() == 0 ) {
264 return get_entry_( index % palette_.size() );
277 std::vector<Color>
color_list(
size_t n = 256 )
const;
299 std::vector<Color>
operator() ( std::vector<double>
const& values )
const;
306 template <
class ForwardIterator>
307 std::vector<Color>
operator()( ForwardIterator first, ForwardIterator last )
const
309 std::vector<Color> result;
310 while( first != last ) {
311 result.push_back(
operator()( *first ) );
332 template <
class ForwardIterator>
335 ForwardIterator first,
338 std::vector<Color> result;
339 while( first != last ) {
340 result.push_back(
operator()( norm, *first ) );
355 Color get_entry_(
size_t index )
const
358 index = palette_.size() - index - 1;
360 return palette_[ index ];
369 Color mask_color_ = { 1.0, 1.0, 0.0 };
370 Color over_color_ = { 1.0, 0.0, 1.0 };
371 Color under_color_ = { 0.0, 1.0, 1.0 };
373 bool clip_under_ =
false;
374 bool clip_over_ =
false;
375 bool reverse_ =
false;
377 std::vector<Color> palette_;
384 #endif // include guard
ColorMap & operator=(ColorMap const &)=default
ColorMap & mask_color(Color value)
Color that indicates values equal to ColorNormalization::mask_value() or non-finite values.
Store a list of colors and offer them as a map for values in range [ 0.0, 1.0 ].
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 palet...
bool reverse() const
Use the palette colors in reverse, back to front.
ColorMap & under_color(Color value)
Color that indicates values less than min().
Base class for color normalization.
ColorMap & over_color(Color value)
Color that indicates values greater than max().
ColorMap & reverse(bool value)
bool clip_over() const
Clip (clamp) values greater than max() to be inside [ min, max ].
Color operator()(double value) const
Return an interpolated color for a value in the range [ 0.0, 1.0 ], representing a position in the pa...
Color const & over_color() const
Color that indicates values greater than max().
ColorMap & clip_under(bool value)
Clip (clamp) values less than min() to be inside [ min, max ].
Color const & under_color() const
Color that indicates values less than min().
std::vector< Color > operator()(ColorNormalization const &norm, ForwardIterator first, ForwardIterator last) const
Return the mapped colors for a range of values, normalized by norm.
ColorMap & clip_over(bool value)
Clip (clamp) values greater than max() to be inside [ min, max ].
ColorMap & clip(bool value)
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
std::vector< Color > operator()(ForwardIterator first, ForwardIterator last) const
Return the mapped colors for a range of values.
bool clip_under() const
Clip (clamp) values less than min() to be inside [ min, max ].
std::vector< Color > const & palette() const
Get the color list currently in use.
ColorMap(std::vector< Color > const &colors)
bool empty() const
Return whether the Palette is empty, that is, no colors were set.
ColorMap & palette(std::vector< Color > const &value)
Color const & mask_color() const
Color that indicates values equal to ColorNormalization::mask_value() or non-finite values.
size_t size() const
Return the size of the map, that is, the number of colors in the list.
Color color(size_t index) const
Return a particular color from the palette, module the palette size.