latest version v1.9 - last update 10 Apr 2010 |
An alias for the rgbPixel type. More...
#include <ltiColors.h>
Public Member Functions | |
rgbColor () | |
rgbColor (const uint32 val) | |
rgbColor (const rgbPixel &other) | |
rgbColor (const ubyte r, const ubyte g, const ubyte b, const ubyte d=0) | |
bool | parseHTML (const std::string &s, bool acceptAlpha=false) |
std::string | makeHTML (bool getAlpha=false) const |
bool | parseName (const std::string &s) |
An alias for the rgbPixel type.
It has several useful methods though that can be used for reading color definitions from external sources.
lti::rgbColor::rgbColor | ( | ) | [inline] |
default constructor
lti::rgbColor::rgbColor | ( | const uint32 | val | ) | [inline] |
constructor with member initialization
Per default a new rgbColor will be initialized with the given value.
val | a 4 byte value to be assign to the three channels + dummy. Note that the order depends on the system endianness:
|
lti::rgbColor::rgbColor | ( | const rgbPixel & | other | ) | [inline] |
Upgrade constructor.
rgb constructor
r | 8 bit value for the red component | |
g | 8 bit value for the green component | |
b | 8 bit value for the blue component | |
d | 8 bit value for the dummy byte (default value 0) |
std::string lti::rgbColor::makeHTML | ( | bool | getAlpha = false |
) | const |
Returns a HTML color definition of this color.
getAlpha | if this is true, the returned definition will also contain the alpha channel. |
bool lti::rgbColor::parseHTML | ( | const std::string & | s, | |
bool | acceptAlpha = false | |||
) |
Parses a HTML color definition string and sets this color to the given one.
In HTML, RGB colors are defined by the following syntax:
Color = #RRGGBB RR = ( 0 | 1 | 2 | ... | 9 | a | A | b | B | ... | f | F ){2} GG = ( 0 | 1 | 2 | ... | 9 | a | A | b | B | ... | f | F ){2} BB = ( 0 | 1 | 2 | ... | 9 | a | A | b | B | ... | f | F ){2}
For instance, "#ff0000" means red (r=255,g=0,b=0). This method also can accept an extension which also includes the alpha value as a fourth component (Color = #RRGGBBAA). If the component is not present, it will be assumed zero. If a string cannot be parsed, the value of this color object will be undefined.
s | the HTML color definition. | |
acceptAlpha | if this is true, the method accepts a fourth component which is interpreted as alpha value. If it is false, such a string will lead to an error. |
bool lti::rgbColor::parseName | ( | const std::string & | s | ) |
Parses a color name (which colors are defined, is system dependent) and sets this color to the giveon one.
If the color name is undefined, the method will return false;
s | the color name |