Logo ROOT   6.18/05
Reference Guide
List of all members | Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
ROOT::Experimental::RPalette Class Reference

A set of colors.

RColors 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...
 
class  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...
 
RColor ResolveRGBAColor (const RColor &col)
 Given a RColor (that might either be a RGBA or a RPalette ordinal), get the RGBA-based color. 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 RPaletteGetPalette (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< 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/RPalette.hxx>

Constructor & Destructor Documentation

◆ RPalette() [1/7]

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

Definition at line 27 of file RPalette.cxx.

◆ RPalette() [2/7]

RPalette::RPalette ( bool  interpolate,
const std::vector< RColor > &  points 
)
private

Definition at line 58 of file RPalette.cxx.

◆ RPalette() [3/7]

ROOT::Experimental::RPalette::RPalette ( )
default

◆ RPalette() [4/7]

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

◆ RPalette() [5/7]

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

◆ RPalette() [6/7]

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

◆ RPalette() [7/7]

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

Member Function Documentation

◆ GetColor()

RColor RPalette::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 RPalette.cxx.

◆ GetPalette()

const RPalette & RPalette::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 101 of file RPalette.cxx.

◆ IsDiscrete()

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

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

Definition at line 108 of file RPalette.hxx.

◆ IsGradient()

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

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

Definition at line 111 of file RPalette.hxx.

◆ IsNormalized()

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

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

Definition at line 105 of file RPalette.hxx.

◆ RegisterPalette()

void RPalette::RegisterPalette ( std::string_view  name,
const RPalette 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 96 of file RPalette.cxx.

◆ ResolveRGBAColor()

RColor ROOT::Experimental::RPalette::ResolveRGBAColor ( const RColor col)
inline

Given a RColor (that might either be a RGBA or a RPalette ordinal), get the RGBA-based color.

Definition at line 118 of file RPalette.hxx.

Member Data Documentation

◆ fColors

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

Palette colors: the color points and their ordinal value.

Definition at line 58 of file RPalette.hxx.

◆ fInterpolate

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

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

Definition at line 61 of file RPalette.hxx.

◆ fNormalized

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

Whether the palette's ordinal numbers are normalized.

Definition at line 64 of file RPalette.hxx.

◆ kDiscrete

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

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

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