Logo ROOT  
Reference Guide
ROOT::Experimental::RColor Class Reference

The color class.

Author
Axel Naumann axel@.nosp@m.cern.nosp@m..ch
Sergey Linev S.Lin.nosp@m.ev@g.nosp@m.si.de
Date
2017-09-26
Warning
This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!

Definition at line 34 of file RColor.hxx.

Public Member Functions

 RColor ()=default
 
 RColor (const RGB_t &rgb)
 Construct color with provided RGB_t value. More...
 
 RColor (const std::string &name)
 Construct color with provided name. More...
 
 RColor (uint8_t r, uint8_t g, uint8_t b)
 Construct color with provided r,g,b values. More...
 
 RColor (uint8_t r, uint8_t g, uint8_t b, float alpha)
 Construct color with provided r,g,b and alpha values. More...
 
std::string AsHex (bool with_alpha=false) const
 Returns color value in hex format like "66FF66" - without any prefix Alpha parameter can be optionally included. More...
 
std::vector< uint8_tAsRGBA () const
 Returns color as RGBA array, trying also convert color name into RGBA value. More...
 
std::string AsSVG () const
 Returns color value as it will be used in SVG drawing It either include hex format #66FF66 or just plain SVG name. More...
 
void Clear ()
 
uint8_t GetAlpha () const
 Returns color alpha (opacity) as uint8_t 0..255. More...
 
float GetAlphaFloat () const
 Returns color alpha (opacity) as float from 0..1. More...
 
uint8_t GetBlue () const
 Returns blue color component 0..255. More...
 
uint8_t GetGreen () const
 Returns green color component 0..255. More...
 
bool GetHLS (float &hue, float &light, float &satur) const
 Return the Hue, Light, Saturation (HLS) definition of this RColor. More...
 
const std::string & GetName () const
 Returns color as plain SVG name like "white" or "lightblue". More...
 
uint8_t GetRed () const
 Returns red color component 0..255. More...
 
const std::vector< uint8_t > & GetRGBA () const
 Returns color as RGBA array - when exists. More...
 
bool HasAlpha () const
 Returns true if color alpha (opacity) was specified. More...
 
bool IsEmpty () const
 Returns true if no color is specified. More...
 
void SetAlpha (uint8_t alpha)
 Set alpha as value from range 0..255. More...
 
void SetAlphaFloat (float alpha)
 Set alpha as float value from range 0..1. More...
 
void SetHLS (float hue, float light, float satur)
 Set the Red Green and Blue (RGB) values from the Hue, Light, Saturation (HLS). More...
 
RColorSetName (const std::string &name)
 Set color as plain SVG name like "white" or "lightblue". More...
 
void SetRGB (const RGB_t &rgb)
 Set r/g/b components of color. More...
 
void SetRGB (uint8_t r, uint8_t g, uint8_t b)
 Set r/g/b components of color. More...
 
void SetRGBA (uint8_t r, uint8_t g, uint8_t b, uint8_t alpha)
 Set r/g/b/a components of color. More...
 

Static Public Attributes

static constexpr RGB_t kAqua {{0, 0xFF, 0xFF}}
 
static constexpr RGB_t kBlack {{0, 0, 0}}
 
static constexpr RGB_t kBlue {{0, 0, 0xff}}
 
static constexpr RGB_t kFuchsia {{0xFF, 0, 0xFF}}
 
static constexpr RGB_t kGreen {{0, 0x80, 0}}
 
static constexpr RGB_t kGrey {{0x80, 0x80, 0x80}}
 
static constexpr RGB_t kLime {{0, 0xFF, 0}}
 
static constexpr RGB_t kMaroon {{0x80, 0, 0}}
 
static constexpr RGB_t kNavy {{0, 0, 0x80}}
 
static constexpr RGB_t kOlive {{0x80, 0x80, 0}}
 
static constexpr float kOpaque {1.}
 
static constexpr RGB_t kPurple {{0x80, 0, 0x80}}
 
static constexpr RGB_t kRed {{0xff, 0, 0}}
 
static constexpr float kSemiTransparent {0.5}
 
static constexpr RGB_t kSilver {{0xc0, 0xc0, 0xc0}}
 
static constexpr RGB_t kTeal {{0, 0x80, 0x80}}
 
static constexpr float kTransparent {0.}
 
static constexpr RGB_t kWhite {{0xff, 0xff, 0xff}}
 
static constexpr RGB_t kYellow {{0xff, 0xff, 0}}
 

Private Types

using RGB_t = std::array< uint8_t, 3 >
 

Private Member Functions

bool SetAlphaHex (const std::string &hex)
 Set Alpha value as hex. More...
 
bool SetRGBHex (const std::string &hex)
 Set RGB values as hex. More...
 

Static Private Member Functions

static bool ConvertToRGB (const std::string &name, std::vector< uint8_t > &rgba)
 Converts string name of color in RGB value - when possible. More...
 
static std::string toHex (uint8_t v)
 Converts integer from 0 to 255 into hex format with two digits like 00. More...
 

Private Attributes

std::string fName
 name of color - if any More...
 
std::vector< uint8_tfRGBA
 RGB + Alpha. More...
 

Friends

bool operator== (const RColor &lhs, const RColor &rhs)
 
class RAttrColor
 

#include <ROOT/RColor.hxx>

Member Typedef Documentation

◆ RGB_t

using ROOT::Experimental::RColor::RGB_t = std::array<uint8_t, 3>
private

Definition at line 38 of file RColor.hxx.

Constructor & Destructor Documentation

◆ RColor() [1/5]

ROOT::Experimental::RColor::RColor ( )
default

◆ RColor() [2/5]

ROOT::Experimental::RColor::RColor ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)
inline

Construct color with provided r,g,b values.

Definition at line 57 of file RColor.hxx.

◆ RColor() [3/5]

ROOT::Experimental::RColor::RColor ( uint8_t  r,
uint8_t  g,
uint8_t  b,
float  alpha 
)
inline

Construct color with provided r,g,b and alpha values.

Definition at line 60 of file RColor.hxx.

◆ RColor() [4/5]

ROOT::Experimental::RColor::RColor ( const RGB_t rgb)
inline

Construct color with provided RGB_t value.

Definition at line 66 of file RColor.hxx.

◆ RColor() [5/5]

ROOT::Experimental::RColor::RColor ( const std::string &  name)
inline

Construct color with provided name.

Definition at line 69 of file RColor.hxx.

Member Function Documentation

◆ AsHex()

std::string RColor::AsHex ( bool  with_alpha = false) const

Returns color value in hex format like "66FF66" - without any prefix Alpha parameter can be optionally included.

Definition at line 162 of file RColor.cxx.

◆ AsRGBA()

std::vector< uint8_t > RColor::AsRGBA ( ) const

Returns color as RGBA array, trying also convert color name into RGBA value.

Returns color as RGBA array, includes optionally alpha parameter 0..255.

Definition at line 146 of file RColor.cxx.

◆ AsSVG()

std::string RColor::AsSVG ( ) const

Returns color value as it will be used in SVG drawing It either include hex format #66FF66 or just plain SVG name.

Definition at line 178 of file RColor.cxx.

◆ Clear()

void ROOT::Experimental::RColor::Clear ( )
inline

Definition at line 200 of file RColor.hxx.

◆ ConvertToRGB()

bool RColor::ConvertToRGB ( const std::string &  name,
std::vector< uint8_t > &  rgba 
)
staticprivate

Converts string name of color in RGB value - when possible.

Definition at line 41 of file RColor.cxx.

◆ GetAlpha()

uint8_t ROOT::Experimental::RColor::GetAlpha ( ) const
inline

Returns color alpha (opacity) as uint8_t 0..255.

Definition at line 162 of file RColor.hxx.

◆ GetAlphaFloat()

float ROOT::Experimental::RColor::GetAlphaFloat ( ) const
inline

Returns color alpha (opacity) as float from 0..1.

Definition at line 175 of file RColor.hxx.

◆ GetBlue()

uint8_t ROOT::Experimental::RColor::GetBlue ( ) const
inline

Returns blue color component 0..255.

Definition at line 152 of file RColor.hxx.

◆ GetGreen()

uint8_t ROOT::Experimental::RColor::GetGreen ( ) const
inline

Returns green color component 0..255.

Definition at line 142 of file RColor.hxx.

◆ GetHLS()

bool RColor::GetHLS ( float &  hue,
float &  light,
float &  satur 
) const

Return the Hue, Light, Saturation (HLS) definition of this RColor.

Returns the Hue, Light, Saturation (HLS) definition of this RColor If color was not specified as hex, method returns false.

Definition at line 193 of file RColor.cxx.

◆ GetName()

const std::string & ROOT::Experimental::RColor::GetName ( ) const
inline

Returns color as plain SVG name like "white" or "lightblue".

Definition at line 189 of file RColor.hxx.

◆ GetRed()

uint8_t ROOT::Experimental::RColor::GetRed ( ) const
inline

Returns red color component 0..255.

Definition at line 132 of file RColor.hxx.

◆ GetRGBA()

const std::vector< uint8_t > & ROOT::Experimental::RColor::GetRGBA ( ) const
inline

Returns color as RGBA array - when exists.

Definition at line 126 of file RColor.hxx.

◆ HasAlpha()

bool ROOT::Experimental::RColor::HasAlpha ( ) const
inline

Returns true if color alpha (opacity) was specified.

Definition at line 120 of file RColor.hxx.

◆ IsEmpty()

bool ROOT::Experimental::RColor::IsEmpty ( ) const
inline

Returns true if no color is specified.

Definition at line 123 of file RColor.hxx.

◆ SetAlpha()

void ROOT::Experimental::RColor::SetAlpha ( uint8_t  alpha)
inline

Set alpha as value from range 0..255.

Definition at line 106 of file RColor.hxx.

◆ SetAlphaFloat()

void ROOT::Experimental::RColor::SetAlphaFloat ( float  alpha)
inline

Set alpha as float value from range 0..1.

Definition at line 95 of file RColor.hxx.

◆ SetAlphaHex()

bool RColor::SetAlphaHex ( const std::string &  hex)
private

Set Alpha value as hex.

Definition at line 135 of file RColor.cxx.

◆ SetHLS()

void RColor::SetHLS ( float  hue,
float  light,
float  satur 
)

Set the Red Green and Blue (RGB) values from the Hue, Light, Saturation (HLS).

Set the color value from the Hue, Light, Saturation (HLS).

Definition at line 240 of file RColor.cxx.

◆ SetName()

RColor & ROOT::Experimental::RColor::SetName ( const std::string &  name)
inline

Set color as plain SVG name like "white" or "lightblue".

Clears RGB component before

Definition at line 181 of file RColor.hxx.

◆ SetRGB() [1/2]

void ROOT::Experimental::RColor::SetRGB ( const RGB_t rgb)
inline

Set r/g/b components of color.

Definition at line 72 of file RColor.hxx.

◆ SetRGB() [2/2]

void ROOT::Experimental::RColor::SetRGB ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)
inline

Set r/g/b components of color.

Definition at line 75 of file RColor.hxx.

◆ SetRGBA()

void ROOT::Experimental::RColor::SetRGBA ( uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  alpha 
)
inline

Set r/g/b/a components of color.

Definition at line 86 of file RColor.hxx.

◆ SetRGBHex()

bool RColor::SetRGBHex ( const std::string &  hex)
private

Set RGB values as hex.

Definition at line 118 of file RColor.cxx.

◆ toHex()

std::string RColor::toHex ( uint8_t  v)
staticprivate

Converts integer from 0 to 255 into hex format with two digits like 00.

Definition at line 105 of file RColor.cxx.

Friends And Related Function Documentation

◆ operator==

bool operator== ( const RColor lhs,
const RColor rhs 
)
friend

Definition at line 226 of file RColor.hxx.

◆ RAttrColor

friend class RAttrColor
friend

Definition at line 36 of file RColor.hxx.

Member Data Documentation

◆ fName

std::string ROOT::Experimental::RColor::fName
private

name of color - if any

Definition at line 43 of file RColor.hxx.

◆ fRGBA

std::vector<uint8_t> ROOT::Experimental::RColor::fRGBA
private

RGB + Alpha.

Definition at line 42 of file RColor.hxx.

◆ kAqua

constexpr RColor::RGB_t RColor::kAqua {{0, 0xFF, 0xFF}}
staticconstexpr

Definition at line 209 of file RColor.hxx.

◆ kBlack

constexpr RColor::RGB_t RColor::kBlack {{0, 0, 0}}
staticconstexpr

Definition at line 206 of file RColor.hxx.

◆ kBlue

constexpr RColor::RGB_t RColor::kBlue {{0, 0, 0xff}}
staticconstexpr

Definition at line 214 of file RColor.hxx.

◆ kFuchsia

constexpr RColor::RGB_t RColor::kFuchsia {{0xFF, 0, 0xFF}}
staticconstexpr

Definition at line 212 of file RColor.hxx.

◆ kGreen

constexpr RColor::RGB_t RColor::kGreen {{0, 0x80, 0}}
staticconstexpr

Definition at line 207 of file RColor.hxx.

◆ kGrey

constexpr RColor::RGB_t RColor::kGrey {{0x80, 0x80, 0x80}}
staticconstexpr

Definition at line 211 of file RColor.hxx.

◆ kLime

constexpr RColor::RGB_t RColor::kLime {{0, 0xFF, 0}}
staticconstexpr

Definition at line 208 of file RColor.hxx.

◆ kMaroon

constexpr RColor::RGB_t RColor::kMaroon {{0x80, 0, 0}}
staticconstexpr

Definition at line 218 of file RColor.hxx.

◆ kNavy

constexpr RColor::RGB_t RColor::kNavy {{0, 0, 0x80}}
staticconstexpr

Definition at line 213 of file RColor.hxx.

◆ kOlive

constexpr RColor::RGB_t RColor::kOlive {{0x80, 0x80, 0}}
staticconstexpr

Definition at line 216 of file RColor.hxx.

◆ kOpaque

constexpr float RColor::kOpaque {1.}
staticconstexpr

Definition at line 224 of file RColor.hxx.

◆ kPurple

constexpr RColor::RGB_t RColor::kPurple {{0x80, 0, 0x80}}
staticconstexpr

Definition at line 210 of file RColor.hxx.

◆ kRed

constexpr RColor::RGB_t RColor::kRed {{0xff, 0, 0}}
staticconstexpr

Definition at line 219 of file RColor.hxx.

◆ kSemiTransparent

constexpr float RColor::kSemiTransparent {0.5}
staticconstexpr

Definition at line 223 of file RColor.hxx.

◆ kSilver

constexpr RColor::RGB_t RColor::kSilver {{0xc0, 0xc0, 0xc0}}
staticconstexpr

Definition at line 217 of file RColor.hxx.

◆ kTeal

constexpr RColor::RGB_t RColor::kTeal {{0, 0x80, 0x80}}
staticconstexpr

Definition at line 215 of file RColor.hxx.

◆ kTransparent

constexpr float RColor::kTransparent {0.}
staticconstexpr

Definition at line 222 of file RColor.hxx.

◆ kWhite

constexpr RColor::RGB_t RColor::kWhite {{0xff, 0xff, 0xff}}
staticconstexpr

Definition at line 221 of file RColor.hxx.

◆ kYellow

constexpr RColor::RGB_t RColor::kYellow {{0xff, 0xff, 0}}
staticconstexpr

Definition at line 220 of file RColor.hxx.

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

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