Logo ROOT   6.12/07
Reference Guide
List of all members | Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
ROOT::Experimental::TPalette Class Reference

A set of colors.

TColors 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 TPaletteGetPalette (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< OrdinalAndColorfColors
 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>

Constructor & Destructor Documentation

◆ TPalette() [1/7]

TPalette::TPalette ( bool  interpolate,
bool  knownNormalized,
const std::vector< OrdinalAndColor > &  points 
)
private

Definition at line 27 of file TPalette.cxx.

◆ TPalette() [2/7]

TPalette::TPalette ( bool  interpolate,
const std::vector< TColor > &  points 
)
private

Definition at line 58 of file TPalette.cxx.

◆ TPalette() [3/7]

ROOT::Experimental::TPalette::TPalette ( )
default

◆ TPalette() [4/7]

ROOT::Experimental::TPalette::TPalette ( const std::vector< OrdinalAndColor > &  interpPoints)
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.

◆ TPalette() [5/7]

ROOT::Experimental::TPalette::TPalette ( Discrete_t  ,
const std::vector< OrdinalAndColor > &  points 
)
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.

◆ TPalette() [6/7]

ROOT::Experimental::TPalette::TPalette ( const std::vector< TColor > &  interpPoints)
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.

◆ TPalette() [7/7]

ROOT::Experimental::TPalette::TPalette ( Discrete_t  ,
const std::vector< TColor > &  points 
)
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.

Member Function Documentation

◆ GetColor()

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.

◆ GetPalette()

const TPalette & TPalette::GetPalette ( std::string_view  name)
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.

◆ IsDiscrete()

bool ROOT::Experimental::TPalette::IsDiscrete ( ) const
inline

Whether the palette is discrete, i.e. does no interpolation between colors.

Definition at line 108 of file TPalette.hxx.

◆ IsGradient()

bool ROOT::Experimental::TPalette::IsGradient ( ) const
inline

Whether the palette is a smooth gradient generated by interpolating between the color points.

Definition at line 111 of file TPalette.hxx.

◆ IsNormalized()

bool ROOT::Experimental::TPalette::IsNormalized ( ) const
inline

Whether the palette is normalized, i.e. covers colors in the ordinal range 0..1.

Definition at line 105 of file TPalette.hxx.

◆ RegisterPalette()

void TPalette::RegisterPalette ( std::string_view  name,
const TPalette palette 
)
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.

◆ ResolveRGBAColor()

TColor ROOT::Experimental::TPalette::ResolveRGBAColor ( const TColor col)
inline

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.

Member Data Documentation

◆ fColors

std::vector<OrdinalAndColor> ROOT::Experimental::TPalette::fColors
private

Palette colors: the color points and their ordinal value.

Definition at line 58 of file TPalette.hxx.

◆ fInterpolate

bool ROOT::Experimental::TPalette::fInterpolate = true
private

Whether to interpolate between the colors (in contrast to picking one of fColors).

Definition at line 61 of file TPalette.hxx.

◆ fNormalized

bool ROOT::Experimental::TPalette::fNormalized = true
private

Whether the palette's ordinal numbers are normalized.

Definition at line 64 of file TPalette.hxx.

◆ kDiscrete

constexpr const Discrete_t ROOT::Experimental::TPalette::kDiscrete {}
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.

Libraries for ROOT::Experimental::TPalette:
[legend]

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