ra4_draw
4bd0201e3d922d42bd545d4b045ed44db33454a4
|
Loads colors from a text configuration file. More...
#include <palette.hpp>
Public Member Functions | |
Palette (const std::string &file, const std::string &palette) | |
Construct from file and palette names. More... | |
Palette (const std::string &palette="default") | |
Construct from palette name. More... | |
Palette (const Palette &)=default | |
Palette & | operator= (const Palette &)=default |
Palette (Palette &&)=default | |
Palette & | operator= (Palette &&)=default |
~Palette ()=default | |
const std::string & | File () const |
Get the file from which colors are read. More... | |
Palette & | File (const std::string &file) |
Set the file from which colors are read. More... | |
const std::string & | PaletteName () const |
Get the name of the palette from which colors are read. More... | |
Palette & | PaletteName (const std::string &palette) |
Set the name of the palette from which colors are read. More... | |
Palette & | PaletteName (const std::string &file, const std::string &palette) |
Set the file and name of the palette from which colors are read. More... | |
Int_t | operator() (const std::string &color_name) const |
Gets the ROOT color number corresponding to a color in the configuration file. More... | |
Static Public Member Functions | |
static Int_t | RGB (Int_t r, Int_t g, Int_t b) |
Gets the ROOT color number corresponding to a given RGB color. More... | |
static Int_t | RGB (Float_t r, Float_t g, Float_t b) |
Gets the ROOT color number corresponding to a given RGB color. More... | |
static Int_t | HSV (Float_t h, Float_t s, Float_t v) |
Gets the ROOT color number corresponding to a given HSV color. More... | |
static Int_t | HLS (Int_t h, Int_t l, Int_t s) |
Gets the ROOT color number corresponding to a given HLS/HSL color. More... | |
static Int_t | HLS (Float_t h, Float_t l, Float_t s) |
Gets the ROOT color number corresponding to a given HLS/HSL color. More... | |
Private Attributes | |
std::string | file_ |
File from which to read color definitions. More... | |
std::string | palette_ |
Palette name from which to read color definitions. More... | |
Loads colors from a text configuration file.
The text files may have multiple palettes defined, with the start of each palette marker by a line containing "[palette_name]" and ended by the start of the next palette or the end of the file. Within each palette, colors are defined on separate lines using their RGB values as "color_name red green blue".
Definition at line 8 of file palette.hpp.
Palette::Palette | ( | const std::string & | file, |
const std::string & | palette | ||
) |
Construct from file and palette names.
[in] | file | File from which to read colors |
[in] | palette | Palette name from which to read colors |
Definition at line 28 of file palette.cpp.
|
explicit |
Construct from palette name.
Colors are read from the file "txt/colors.txt"
[in] | palette | Palette name from which to read colors |
Definition at line 40 of file palette.cpp.
|
default |
|
default |
|
default |
const string & Palette::File | ( | ) | const |
Get the file from which colors are read.
Definition at line 48 of file palette.cpp.
References file_.
Palette & Palette::File | ( | const std::string & | file | ) |
Set the file from which colors are read.
[in] | file | File from which colors are read |
Definition at line 58 of file palette.cpp.
References file_.
|
static |
Gets the ROOT color number corresponding to a given HLS/HSL color.
[in] | h | Hue in range [0, 255] |
[in] | l | Saturation in range [0, 255]. |
[in] | s | Value or brightness in range [0, 255] |
Definition at line 193 of file palette.cpp.
References RGB().
|
static |
Gets the ROOT color number corresponding to a given HLS/HSL color.
[in] | h | Hue in range [0., 360.] |
[in] | l | Saturation in range [0., 1.]. |
[in] | s | Value or brightness in range [0., 1.] |
Definition at line 209 of file palette.cpp.
References RGB().
|
static |
Gets the ROOT color number corresponding to a given HSV color.
[in] | h | Hue in range [0., 360.] |
[in] | s | Saturation in range [0., 1.]. |
[in] | v | Value or brightness in range [0., 1.] |
Definition at line 177 of file palette.cpp.
References RGB().
Int_t Palette::operator() | ( | const std::string & | color_name | ) | const |
Gets the ROOT color number corresponding to a color in the configuration file.
[in] | color_name | Name of color in current palette for which to obtain color number |
Definition at line 104 of file palette.cpp.
References DBG, ERROR, file_, palette_, ReplaceAll(), and RGB().
const string & Palette::PaletteName | ( | ) | const |
Get the name of the palette from which colors are read.
Definition at line 67 of file palette.cpp.
References palette_.
Referenced by PaletteName().
Palette & Palette::PaletteName | ( | const std::string & | palette | ) |
Set the name of the palette from which colors are read.
[in] | palette | Name of the palette from which colors are read |
Definition at line 77 of file palette.cpp.
References file_, and PaletteName().
Palette & Palette::PaletteName | ( | const std::string & | file, |
const std::string & | palette | ||
) |
Set the file and name of the palette from which colors are read.
[in] | file | File from which colors are read |
[in] | palette | Name of the palette from which colors are read |
Definition at line 89 of file palette.cpp.
|
static |
Gets the ROOT color number corresponding to a given RGB color.
[in] | r | Red value in range [0, 255] |
[in] | g | Green value in range [0, 255] |
[in] | b | Blue value in range [0, 255] |
Definition at line 149 of file palette.cpp.
Referenced by HLS(), HSV(), main(), and operator()().
|
static |
Gets the ROOT color number corresponding to a given RGB color.
[in] | r | Red value in range [0., 1.] |
[in] | g | Green value in range [0., 1.] |
[in] | b | Blue value in range [0., 1.] |
Definition at line 163 of file palette.cpp.
|
private |
File from which to read color definitions.
Definition at line 38 of file palette.hpp.
Referenced by File(), operator()(), and PaletteName().
|
private |
Palette name from which to read color definitions.
Definition at line 39 of file palette.hpp.
Referenced by operator()(), and PaletteName().