A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color. More...
#include <RGBAColor.h>
Public Types | |
enum | NameFormat { HexRgb, HexArgb } |
NameFormat enum. More... | |
Public Member Functions | |
Initializer Methods | |
Methods related to instantiation and destruction. | |
RGBAColor () | |
Default constructor of a new color. More... | |
RGBAColor (int rgba) | |
It initializes a new color with the given value. More... | |
RGBAColor (int r, int g, int b, int a) | |
It initializes a new color. More... | |
RGBAColor (const std::string &hexColor) | |
It initializes a new color from a given hex RGB-encoded string. More... | |
~RGBAColor () | |
Destructor. More... | |
Accessor methods | |
Methods used to get or set properties. | |
te::color::RGBAColor & | operator= (const RGBAColor &color) |
Assigns a copy of a color to this color, and returns a reference to it. More... | |
te::color::RGBAColor & | operator= (const int &rgba) |
Assigns a copy of a color to this color. More... | |
bool | operator== (const RGBAColor &color) const |
It compares the colors are iqual. More... | |
bool | operator!= (const RGBAColor &color) const |
It compares the colors are different. More... | |
int | getRed () const |
It returns the red component color value (a value from 0 to 255). More... | |
int | getGreen () const |
It returns the green component color value (a value from 0 to 255). More... | |
int | getBlue () const |
It returns the blue component color value (a value from 0 to 255). More... | |
int | getAlpha () const |
It returns the alpha component color value (a value from 0 to 255). More... | |
void | getRgba (int *r, int *g, int *b, int *a=0) const |
It gets the color value. More... | |
int | getRgba () const |
It returns the color value (0xAARRGGBB). More... | |
void | setColor (const std::string &hexColor) |
It sets the color using a two hexadecimal RGB-encoded color. More... | |
std::string | getColor (const NameFormat format=HexRgb) const |
It gets the color encoded using two hexadecimal digits per primary-color component, in the order Red, Green, Blue, if HexRgb format, or Alpha, Red, Green, Blue, if HexArgb format, prefixed with a hash (#) sign. More... | |
void | setColor (int r, int g, int b, int a=255) |
It sets the color. More... | |
void | setColor (int rgba) |
It sets the color. More... | |
Private Attributes | |
int | m_rgba |
It returns the internal representation as a 32-bits RGBA color. More... | |
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Internally the color is represented by an integer of 32-bits as the following:
Definition at line 57 of file RGBAColor.h.
NameFormat enum.
Possible ways for color name format.
Enumerator | |
---|---|
HexRgb |
enum value, format #RRGGBB |
HexArgb |
enum value, format #AARRGGBB |
Definition at line 64 of file RGBAColor.h.
|
inline |
Default constructor of a new color.
Definition at line 255 of file RGBAColor.h.
|
inline |
It initializes a new color with the given value.
rgba | The color encoded as an integer. |
Definition at line 260 of file RGBAColor.h.
|
inline |
It initializes a new color.
r | Red component (range from 0 to 255). |
g | Green component (range from 0 to 255). |
b | Blue component (range from 0 to 255). |
a | Alpha component. A range from 0 to 255 (see the macro TE_OPAQUE and TE_TRANSPARENT for the values of totally transparent and totally opaque). |
Definition at line 265 of file RGBAColor.h.
|
inline |
It initializes a new color from a given hex RGB-encoded string.
hexColor | The color value is RGB-encoded using two hexadecimal digits per primary-color component, in the order Red, Green, Blue, prefixed with a hash (#) sign. The hexadecimal digits between A and F may be in uppercase or lowercase. |
Definition at line 274 of file RGBAColor.h.
References setColor().
|
inline |
Destructor.
Definition at line 279 of file RGBAColor.h.
|
inline |
It returns the alpha component color value (a value from 0 to 255).
Definition at line 322 of file RGBAColor.h.
References m_rgba.
Referenced by getColor().
|
inline |
It returns the blue component color value (a value from 0 to 255).
Definition at line 317 of file RGBAColor.h.
References m_rgba.
Referenced by getColor().
|
inline |
It gets the color encoded using two hexadecimal digits per primary-color component, in the order Red, Green, Blue, if HexRgb format, or Alpha, Red, Green, Blue, if HexArgb format, prefixed with a hash (#) sign.
format | Formar of the string return. |
Definition at line 371 of file RGBAColor.h.
References getAlpha(), getBlue(), getGreen(), getRed(), and HexRgb.
|
inline |
It returns the green component color value (a value from 0 to 255).
Definition at line 312 of file RGBAColor.h.
References m_rgba.
Referenced by getColor().
|
inline |
It returns the red component color value (a value from 0 to 255).
Definition at line 307 of file RGBAColor.h.
References m_rgba.
Referenced by getColor().
|
inline |
It gets the color value.
r | Red component. |
g | Green component. |
b | Blue component. |
a | Alpha component. |
Definition at line 327 of file RGBAColor.h.
References m_rgba.
|
inline |
It returns the color value (0xAARRGGBB).
Definition at line 336 of file RGBAColor.h.
References m_rgba.
|
inline |
It compares the colors are different.
color | The rgba color to be compared. |
Definition at line 302 of file RGBAColor.h.
References operator==().
|
inline |
Assigns a copy of a color to this color, and returns a reference to it.
color | The rgba color to be copied. |
Definition at line 283 of file RGBAColor.h.
References m_rgba.
|
inline |
Assigns a copy of a color to this color.
rgba | the 32-bit RGBA (Red-Green-Blue-Alpha channel) color to be copied. |
Definition at line 289 of file RGBAColor.h.
References m_rgba.
|
inline |
It compares the colors are iqual.
color | The rgba color to be compared. |
Definition at line 295 of file RGBAColor.h.
References m_rgba.
Referenced by operator!=().
|
inline |
It sets the color using a two hexadecimal RGB-encoded color.
hexColor | The color value is RGB-encoded using two hexadecimal digits per primary-color component, in the order Red, Green, Blue, prefixed with a hash (#) sign. The hexadecimal digits between A and F may be in either uppercase or lowercase. |
Definition at line 341 of file RGBAColor.h.
References te::core::GetDecimalFromHexNotCS(), and TE_OPAQUE.
Referenced by RGBAColor().
|
inline |
It sets the color.
r | Red component (range from 0 to 255). |
g | Green component (range from 0 to 255). |
b | Blue component (range from 0 to 255). |
a | Alpha component. A range from 0 to 255 (see the macro TE_OPAQUE and TE_TRANSPARENT for the values of totally transparent and totally opaque). |
Definition at line 389 of file RGBAColor.h.
References m_rgba.
|
inline |
It sets the color.
rgba | The color represented by a number of 4 bytes, where the values ??are in the following order: alpha, red, green and blue. The alpha is the most significant byte. |
Definition at line 394 of file RGBAColor.h.
References m_rgba.
|
private |
It returns the internal representation as a 32-bits RGBA color.
Definition at line 252 of file RGBAColor.h.
Referenced by getAlpha(), getBlue(), getGreen(), getRed(), getRgba(), operator=(), operator==(), and setColor().