ROOT 6.12/07 Reference Guide |
A set of colors.
TColor
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 TPalette.hxx.
Classes | |
struct | Discrete_t |
Tag type used to signal that the palette's colors should not be interpolated. More... | |
class | OrdinalAndColor |
An ordinal value and its associated color. More... | |
Public Member Functions | |
TPalette ()=default | |
TPalette (const std::vector< OrdinalAndColor > &interpPoints) | |
Construct a TPalette from a vector of (ordinal|color) pairs as interpolation points. More... | |
TPalette (Discrete_t, const std::vector< OrdinalAndColor > &points) | |
Construct a TPalette from a vector of (ordinal|color) pairs. More... | |
TPalette (const std::vector< TColor > &interpPoints) | |
Construct a normalized TPalette from a vector of colors as interpolation points. More... | |
TPalette (Discrete_t, const std::vector< TColor > &points) | |
Construct a normalized TPalette from a vector of colors. More... | |
TColor | 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... | |
TColor | ResolveRGBAColor (const TColor &col) |
Given a TColor (that might either be a RGBA or a TPalette ordinal), get the RGBA-based color. More... | |
Static Public Member Functions | |
Global Palettes | |
static void | RegisterPalette (std::string_view name, const TPalette &palette) |
Register a palette in the set of global palettes, making it available to GetPalette() . More... | |
static const TPalette & | 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 | |
TPalette (bool interpolate, bool knownNormalized, const std::vector< OrdinalAndColor > &points) | |
TPalette (bool interpolate, const std::vector< TColor > &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/TPalette.hxx>
|
private |
Definition at line 27 of file TPalette.cxx.
|
private |
Definition at line 58 of file TPalette.cxx.
|
default |
|
inline |
Construct a TPalette 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 TPalette.hxx.
|
inline |
Construct a TPalette 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 TPalette.hxx.
|
inline |
Construct a normalized TPalette 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 TPalette.hxx.
|
inline |
Construct a normalized TPalette 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 TPalette.hxx.
TColor TPalette::GetColor | ( | double | ordinal | ) |
Get the color associated with the ordinal value.
The value is expected to be 0..1 for a normalized palette.
Definition at line 62 of file TPalette.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 100 of file TPalette.cxx.
|
inline |
Whether the palette is discrete, i.e. does no interpolation between colors.
Definition at line 108 of file TPalette.hxx.
|
inline |
Whether the palette is a smooth gradient generated by interpolating between the color points.
Definition at line 111 of file TPalette.hxx.
|
inline |
Whether the palette is normalized, i.e. covers colors in the ordinal range 0..1.
Definition at line 105 of file TPalette.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 95 of file TPalette.cxx.
Given a TColor (that might either be a RGBA or a TPalette ordinal), get the RGBA-based color.
Definition at line 118 of file TPalette.hxx.
|
private |
Palette colors: the color points and their ordinal value.
Definition at line 58 of file TPalette.hxx.
|
private |
Whether to interpolate between the colors (in contrast to picking one of fColors).
Definition at line 61 of file TPalette.hxx.
|
private |
Whether the palette's ordinal numbers are normalized.
Definition at line 64 of file TPalette.hxx.
|
static |
Tag value used to signal that the palette's colors should not be interpolated.
Can be passed to the constructor: TPalette palette(TPalette::kDiscrete, {{-100., TColor::kWhite}, {100., TColor::kRed}})
Definition at line 76 of file TPalette.hxx.