Added a new constructor that takes single Uint32 to Color

This commit is contained in:
FRex 2014-10-10 17:34:55 +02:00 committed by Lukas Dürrenberger
parent 8dd31f2f52
commit 88ec48cb85
2 changed files with 19 additions and 0 deletions

View File

@ -61,6 +61,14 @@ public:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = 255); Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = 255);
////////////////////////////////////////////////////////////
/// \brief Construct the color from 32 bit unsigned integer
///
/// \param color Number containing the RGBA components (in that order)
///
////////////////////////////////////////////////////////////
Color(Uint32 color);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Static member data // Static member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -67,6 +67,17 @@ a(alpha)
} }
////////////////////////////////////////////////////////////
Color::Color(Uint32 color) :
r((color & 0xff000000) >> 24),
g((color & 0x00ff0000) >> 16),
b((color & 0x0000ff00) >> 8 ),
a((color & 0x000000ff) >> 0 )
{
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool operator ==(const Color& left, const Color& right) bool operator ==(const Color& left, const Color& right)
{ {