te::color::RGBAColor Class Reference

A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color. More...

#include <RGBAColor.h>

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::RGBAColoroperator= (const RGBAColor &color)
 Assigns a copy of a color to this color, and returns a reference to it. More...
 
te::color::RGBAColoroperator= (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
 It gets the color encoded using two hexadecimal digits per primary-color component, in the order Red, Green, Blue, 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...
 

Detailed Description

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:

  • bits 0-7: blue
  • bits 8-15: green
  • bits 16-23: red
  • bits 24-31: alpha. See the macro TE_OPAQUE and TE_TRANSPARENT for the values of totally transparent and totally opaque.

Definition at line 57 of file RGBAColor.h.

Constructor & Destructor Documentation

te::color::RGBAColor::RGBAColor ( )
inline

Default constructor of a new color.

Definition at line 243 of file RGBAColor.h.

te::color::RGBAColor::RGBAColor ( int  rgba)
inline

It initializes a new color with the given value.

Parameters
rgbaThe color encoded as an integer.

Definition at line 248 of file RGBAColor.h.

te::color::RGBAColor::RGBAColor ( int  r,
int  g,
int  b,
int  a 
)
inline

It initializes a new color.

Parameters
rRed component (range from 0 to 255).
gGreen component (range from 0 to 255).
bBlue component (range from 0 to 255).
aAlpha 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 253 of file RGBAColor.h.

te::color::RGBAColor::RGBAColor ( const std::string &  hexColor)
inline

It initializes a new color from a given hex RGB-encoded string.

Parameters
hexColorThe 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 262 of file RGBAColor.h.

References setColor().

te::color::RGBAColor::~RGBAColor ( )
inline

Destructor.

Definition at line 267 of file RGBAColor.h.

Member Function Documentation

int te::color::RGBAColor::getAlpha ( ) const
inline

It returns the alpha component color value (a value from 0 to 255).

Returns
The alpha component color value. It is a value from 0 to 255 (see the macro TE_OPAQUE and TE_TRANSPARENT for the values of totally transparent and totally opaque).

Definition at line 310 of file RGBAColor.h.

References m_rgba.

int te::color::RGBAColor::getBlue ( ) const
inline

It returns the blue component color value (a value from 0 to 255).

Returns
The blue component color value (a value from 0 to 255).

Definition at line 305 of file RGBAColor.h.

References m_rgba.

Referenced by getColor().

std::string te::color::RGBAColor::getColor ( ) const
inline

It gets the color encoded using two hexadecimal digits per primary-color component, in the order Red, Green, Blue, prefixed with a hash (#) sign.

Returns
A string that represents the color encoded using two hexadecimal digits per primary-color component. e.g. #FF0000
Note
The hexadecimal digits between A and F will be uppercase.

Definition at line 349 of file RGBAColor.h.

References getBlue(), getGreen(), and getRed().

int te::color::RGBAColor::getGreen ( ) const
inline

It returns the green component color value (a value from 0 to 255).

Returns
The green component color value (a value from 0 to 255).

Definition at line 300 of file RGBAColor.h.

References m_rgba.

Referenced by getColor().

int te::color::RGBAColor::getRed ( ) const
inline

It returns the red component color value (a value from 0 to 255).

Returns
The red component color value (a value from 0 to 255).

Definition at line 295 of file RGBAColor.h.

References m_rgba.

Referenced by getColor().

void te::color::RGBAColor::getRgba ( int *  r,
int *  g,
int *  b,
int *  a = 0 
) const
inline

It gets the color value.

Parameters
rRed component.
gGreen component.
bBlue component.
aAlpha component.

Definition at line 315 of file RGBAColor.h.

References m_rgba.

int te::color::RGBAColor::getRgba ( ) const
inline

It returns the color value (0xAARRGGBB).

Returns
It returns a number of 4 bytes. The values are on the following order: alpha, red, green and blue. The alpha is the most significant byte.

Definition at line 324 of file RGBAColor.h.

References m_rgba.

bool te::color::RGBAColor::operator!= ( const RGBAColor color) const
inline

It compares the colors are different.

Parameters
colorThe rgba color to be compared.
Returns
Returns true if this color has not the same RGB and alpha values.

Definition at line 290 of file RGBAColor.h.

References operator==().

te::color::RGBAColor & te::color::RGBAColor::operator= ( const RGBAColor color)
inline

Assigns a copy of a color to this color, and returns a reference to it.

Parameters
colorThe rgba color to be copied.
Returns
Returns a reference to it.

Definition at line 271 of file RGBAColor.h.

References m_rgba.

te::color::RGBAColor & te::color::RGBAColor::operator= ( const int &  rgba)
inline

Assigns a copy of a color to this color.

Parameters
rgbathe 32-bit RGBA (Red-Green-Blue-Alpha channel) color to be copied.
Returns
Returns a reference to it.

Definition at line 277 of file RGBAColor.h.

References m_rgba.

bool te::color::RGBAColor::operator== ( const RGBAColor color) const
inline

It compares the colors are iqual.

Parameters
colorThe rgba color to be compared.
Returns
Returns true if this color has the same RGB and alpha values.

Definition at line 283 of file RGBAColor.h.

References m_rgba.

Referenced by operator!=().

void te::color::RGBAColor::setColor ( const std::string &  hexColor)
inline

It sets the color using a two hexadecimal RGB-encoded color.

Parameters
hexColorThe 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 329 of file RGBAColor.h.

References te::common::GetDecimalFromHexNotCS(), and TE_OPAQUE.

Referenced by RGBAColor().

void te::color::RGBAColor::setColor ( int  r,
int  g,
int  b,
int  a = 255 
)
inline

It sets the color.

Parameters
rRed component (range from 0 to 255).
gGreen component (range from 0 to 255).
bBlue component (range from 0 to 255).
aAlpha 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 357 of file RGBAColor.h.

References m_rgba.

void te::color::RGBAColor::setColor ( int  rgba)
inline

It sets the color.

Parameters
rgbaThe 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 362 of file RGBAColor.h.

References m_rgba.

Member Data Documentation

int te::color::RGBAColor::m_rgba
private

It returns the internal representation as a 32-bits RGBA color.

Returns
The internal representation as a 32-bit RGBA color.Internal color, stored as a 32-bit.

Definition at line 240 of file RGBAColor.h.

Referenced by getAlpha(), getBlue(), getGreen(), getRed(), getRgba(), operator=(), operator==(), and setColor().


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