Implemented sf::Color::toInteger() to complement the new sf::Color constructor.

This commit is contained in:
Lukas Dürrenberger 2015-02-11 12:09:33 +01:00
parent 88ec48cb85
commit 1f2bc148fe
2 changed files with 17 additions and 2 deletions

View File

@ -62,12 +62,20 @@ 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 /// \brief Construct the color from 32-bit unsigned integer
/// ///
/// \param color Number containing the RGBA components (in that order) /// \param color Number containing the RGBA components (in that order)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Color(Uint32 color); explicit Color(Uint32 color);
////////////////////////////////////////////////////////////
/// \brief Retrieve the color as a 32-bit unsigned integer
///
/// \return Color represented as a 32-bit unsigned integer
///
////////////////////////////////////////////////////////////
Uint32 toInteger();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Static member data // Static member data

View File

@ -78,6 +78,13 @@ a((color & 0x000000ff) >> 0 )
} }
////////////////////////////////////////////////////////////
Uint32 Color::toInteger()
{
return (r << 24) | (g << 16) | (b << 8) | a;
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool operator ==(const Color& left, const Color& right) bool operator ==(const Color& left, const Color& right)
{ {