A set of colors.
RColor
s can be conveniently generated from this.
A palette associates a color with an ordinal number: for a normalized palette, this number ranges from 0..1. For user-valued palettes, the palette yields a color for user-coordinates (for instance histogram content), in an arbitrary range.
A palette can be a smooth gradients by interpolation of support points, or a set of discrete colors.
Definition at line 38 of file RPalette.hxx.
Classes | |
struct | Discrete_t |
Tag type used to signal that the palette's colors should not be interpolated. More... | |
struct | OrdinalAndColor |
An ordinal value and its associated color. More... | |
Public Member Functions | |
RPalette ()=default | |
RPalette (const std::vector< OrdinalAndColor > &interpPoints) | |
Construct a RPalette from a vector of (ordinal|color) pairs as interpolation points. More... | |
RPalette (const std::vector< RColor > &interpPoints) | |
Construct a normalized RPalette from a vector of colors as interpolation points. More... | |
RPalette (Discrete_t, const std::vector< OrdinalAndColor > &points) | |
Construct a RPalette from a vector of (ordinal|color) pairs. More... | |
RPalette (Discrete_t, const std::vector< RColor > &points) | |
Construct a normalized RPalette from a vector of colors. More... | |
RColor | GetColor (double ordinal) |
Get the color associated with the ordinal value. More... | |
bool | IsDiscrete () const |
Whether the palette is discrete, i.e. does no interpolation between colors. More... | |
bool | IsGradient () const |
Whether the palette is a smooth gradient generated by interpolating between the color points. More... | |
bool | IsNormalized () const |
Whether the palette is normalized, i.e. covers colors in the ordinal range 0..1. More... | |
Static Public Member Functions | |
Global Palettes | |
static void | RegisterPalette (std::string_view name, const RPalette &palette) |
Register a palette in the set of global palettes, making it available to GetPalette() . More... | |
static const RPalette & | GetPalette (std::string_view name="") |
Get a global palette by name. More... | |
Static Public Attributes | |
static constexpr const Discrete_t | kDiscrete {} |
Tag value used to signal that the palette's colors should not be interpolated. More... | |
Private Member Functions | |
RPalette (bool interpolate, bool knownNormalized, const std::vector< OrdinalAndColor > &points) | |
RPalette (bool interpolate, const std::vector< RColor > &points) | |
Private Attributes | |
std::vector< OrdinalAndColor > | fColors |
Palette colors: the color points and their ordinal value. More... | |
bool | fInterpolate = true |
Whether to interpolate between the colors (in contrast to picking one of fColors). More... | |
bool | fNormalized = true |
Whether the palette's ordinal numbers are normalized. More... | |
#include <ROOT/RPalette.hxx>
|
private |
Definition at line 20 of file RPalette.cxx.
Definition at line 51 of file RPalette.cxx.
|
default |
|
inline |
Construct a RPalette from a vector of (ordinal|color) pairs as interpolation points.
Palette colors will be these points for the ordinal, and interpolated in between the ordinal points. The points will be sorted. The palette is normalized if the lowest ordinal is 0. and the highest ordinal is 1.; otherwise, the palette is a user-valued palette.
Definition at line 85 of file RPalette.hxx.
|
inline |
Construct a RPalette from a vector of (ordinal|color) pairs.
For a given value, the palette returns the color with an ordinal that is closest to the value. The points will be sorted. The palette is normalized if the lowest ordinal is 0. and the highest ordinal is 1.; otherwise, the palette is a user-valued palette.
Definition at line 91 of file RPalette.hxx.
|
inline |
Construct a normalized RPalette from a vector of colors as interpolation points.
The ordinal associated with each color is equidistant from 0..1, i.e. for three colors it will be 0., 0.5 and 1, respectively. Palette colors will be these points for the ordinal associated with the color, and interpolated in between the ordinal points.
Definition at line 97 of file RPalette.hxx.
|
inline |
Construct a normalized RPalette from a vector of colors.
The ordinal associated with each color is equidistant from 0..1, i.e. for three colors it will be 0., 0.5 and 1, respectively. For a given value, the palette returns the color with an ordinal that is closest to the value.
Definition at line 102 of file RPalette.hxx.
Get the color associated with the ordinal value.
The value is expected to be 0..1 for a normalized palette.
Definition at line 55 of file RPalette.cxx.
|
static |
Get a global palette by name.
Returns an empty palette if no palette with that name is known. This function is not thread safe; any concurrent call to global Palette manipulation must be synchronized!
Definition at line 142 of file RPalette.cxx.
|
inline |
Whether the palette is discrete, i.e. does no interpolation between colors.
Definition at line 108 of file RPalette.hxx.
|
inline |
Whether the palette is a smooth gradient generated by interpolating between the color points.
Definition at line 111 of file RPalette.hxx.
|
inline |
Whether the palette is normalized, i.e. covers colors in the ordinal range 0..1.
Definition at line 105 of file RPalette.hxx.
|
static |
Register a palette in the set of global palettes, making it available to GetPalette()
.
This function is not thread safe; any concurrent call to global Palette manipulation must be synchronized!
Definition at line 137 of file RPalette.cxx.
|
private |
Palette colors: the color points and their ordinal value.
Definition at line 58 of file RPalette.hxx.
|
private |
Whether to interpolate between the colors (in contrast to picking one of fColors).
Definition at line 61 of file RPalette.hxx.
|
private |
Whether the palette's ordinal numbers are normalized.
Definition at line 64 of file RPalette.hxx.
|
staticconstexpr |
Tag value used to signal that the palette's colors should not be interpolated.
Can be passed to the constructor: RPalette palette(RPalette::kDiscrete, {{-100., RColor::kWhite}, {100., RColor::kRed}})
Definition at line 76 of file RPalette.hxx.