Class for palette definition. More...
#include <palette.hpp>
Classes | |
struct | Entry |
Palette defining entry. More... | |
Public Member Functions | |
Palette () | |
Default constructor for default black and white palette. | |
Palette (const std::vector< Entry > &entries) | |
Constructor for defined palette. | |
Color | operator() (double x) const |
Return the interpolated color value from palette. | |
void | clear (void) |
Clear current palette. | |
void | push_back (const Color &color, double val) |
Pushes new entry to palette. | |
void | norm (void) |
Normalize palette entries. | |
void | set_stepped_palette (int steps) |
Set stepped palette. | |
void | debug_print (std::ostream &os) const |
Print debugging information to os. |
Class for palette definition.
Palette is an object that contains a list of colors and corresponding values. The colors are interpolated linearly between the defined points for a smooth color palette. The palette values are normed so that the end points of palette have values 0.0 and 1.0.
Palette::Palette | ( | ) |
Default constructor for default black and white palette.
Palette::Palette | ( | const std::vector< Entry > & | entries | ) |
Constructor for defined palette.
The values are normed to range from 0.0 to 1.0.
void Palette::clear | ( | void | ) |
Clear current palette.
Leaves palette with no colors. Used with push_back() to build new palettes on-line.
void Palette::debug_print | ( | std::ostream & | os | ) | const |
Print debugging information to os.
void Palette::norm | ( | void | ) |
Normalize palette entries.
Normalize palette to range from 0.0 to 1.0.
Color Palette::operator() | ( | double | x | ) | const |
Return the interpolated color value from palette.
Makes and interpolated color value at value x, where 0 <= x <= 1. If palette has no colors, black will be returned. If palette has one color, that color will be returned. With two or more colors the value returned is interpolated from the colors. Outside the defined range, the closest color value is returned (color 0 if x < 0 and color N-1 if x > 1). If stepped palette is enabled, the palette shades will be limited and hard limits will be shown on palette sweeps.
void Palette::push_back | ( | const Color & | color, |
double | val | ||
) |
void Palette::set_stepped_palette | ( | int | steps | ) |
Set stepped palette.
If steps is less than or equal to 1 a regular interpolated palette will be used (default), otherwise steps is used as the number of separate shades in the palette.