class: etk::Color
Description:
The color class is a template to abstract the color implementation choice.
It is important to note that the color choice denpznd on the level of developent.
For example :
Graphic application use:
Image in 3/4 bytes for rgb(a)
Color description in char : '#F6780FFF' or the equivalent number:0xF6780FFF
middleware will mainely use a the 4 separate value with 1 byte for each.
graphic interface (openGL) store image in 1/2/3/4 bytes color and interpolate it in 'n' float. And note that the user color is sored in float.
Then with this class we abstract the transformation format and set an easy same way to use the color independing of the developpement level.
Some of the basic color is defined in the namespace: [namespace[etk::color]].
Associated Namespace:
Constructor and Destructor:
+ Color (void );
+ Color (double _r,
double _g,
double _b,
double _a);
+ Color (float _r,
float _g,
float _b,
float _a);
+ Color (uint8_t _r,
uint8_t _g,
uint8_t _b,
uint8_t _a);
+ Color (int _r,
int _g,
int _b,
int _a);
+ Color (uint32_t _input);
+ Color (const etk::Color<float> & _obj);
+ Color (const etk::Color<uint8_t> & _obj);
+ Color (const std::string & _input);
Synopsis:
+ Color<MY_TYPE> & operator = (const etk::Color<MY_TYPE> & _input);
+ bool operator != (const etk::Color<MY_TYPE> & _obj) const;
+ bool operator == (const etk::Color<MY_TYPE> & _obj) const;
+ uint32_t get (void ) const;
+ void set (float _r,
float _g,
float _b,
float _a);
+ void set (uint8_t _r,
uint8_t _g,
uint8_t _b,
uint8_t _a);
+ void set (int _r,
int _g,
int _b,
int _a);
+ std::string getHexString (void ) const;
+ std::string getString (void ) const;
+ MY_TYPE r (void ) const;
+ MY_TYPE g (void ) const;
+ MY_TYPE b (void ) const;
+ MY_TYPE a (void ) const;
+ void setR (MY_TYPE _r);
+ void setG (MY_TYPE _g);
+ void setB (MY_TYPE _b);
+ void setA (MY_TYPE _a);
Detail:
Color
+ Color (void );
Constructor. It does not initialise element of class.
Color
+ Color (double _r,
double _g,
double _b,
double _a);
+ Color (float _r,
float _g,
float _b,
float _a);
+ Color (uint8_t _r,
uint8_t _g,
uint8_t _b,
uint8_t _a);
+ Color (int _r,
int _g,
int _b,
int _a);
Contructor with request initialisation.
Parameter [input]: | _r | Red color. |
Parameter [input]: | _g | Green color. |
Parameter [input]: | _b | Blue color. |
Parameter [input]: | _a | Alpha blending. |
Color
+ Color (uint32_t _input);
Constructor with the single integer input.
Note: Not forger the alpha blending at the end
Color
+ Color (const etk::Color<float> & _obj);
+ Color (const etk::Color<uint8_t> & _obj);
Copy contructor or convert contructor
Color
+ Color (const std::string & _input);
String extractor constructor.
Parameter [input]: | _input | Color string to parse. it can be : "#rrggbb", "rgb", "rrggbbaa", "rgba", "blueviolet" ... |
operator =
+ Color<MY_TYPE> & operator = (const etk::Color<MY_TYPE> & _input);
Asignemement operator
operator !=
+ bool operator != (const etk::Color<MY_TYPE> & _obj) const;
Different comparaison operator.
Parameter [input]: | _obj | Color object to compare. |
Return: | | true This is not the same color<br/>false This is the same color. |
operator ==
+ bool operator == (const etk::Color<MY_TYPE> & _obj) const;
Equality comparaison operator.
Parameter [input]: | _obj | Color object to compare. |
Return: | | true This is the same color.<br/>false The color are different. |
get
+ uint32_t get (void ) const;
Return: | | Color in unsigned integer |
set
+ void set (float _r,
float _g,
float _b,
float _a);
+ void set (uint8_t _r,
uint8_t _g,
uint8_t _b,
uint8_t _a);
+ void set (int _r,
int _g,
int _b,
int _a);
Set the specified color elements.
Parameter [input]: | _r | Red color. |
Parameter [input]: | _g | Green color. |
Parameter [input]: | _b | Blue color. |
Parameter [input]: | _a | Alpha blending. |
getHexString
+ std::string getHexString (void ) const;
Convert the color in an hexedecimal string ("0xFEDCBA98")
Return: | | The formated string |
getString
+ std::string getString (void ) const;
Convert the color in an generic string value ("#FEDCBA98")
Return: | | The formated string |
r
+ MY_TYPE r (void ) const;
Get red color.
g
+ MY_TYPE g (void ) const;
Get green color.
b
+ MY_TYPE b (void ) const;
Get blue color.
a
+ MY_TYPE a (void ) const;
Get alpha blending.
Return: | | The alpha blending. |
setR
+ void setR (MY_TYPE _r);
Set red color.
Parameter [input]: | _r | The red color to set. |
setG
+ void setG (MY_TYPE _g);
Set green color.
Parameter [input]: | _g | The green color to set. |
setB
+ void setB (MY_TYPE _b);
Set blue color.
Parameter [input]: | _b | The blue color to set. |
setA
+ void setA (MY_TYPE _a);
Set alpha blending.