mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-25 05:03:36 +01:00
Merge pull request #71 from LaurentGomila/feature/color_int_ctor
Added the ctor to create a sfColor from an sfUint32
This commit is contained in:
commit
2ca7fbfb61
2 files changed
+37
No files matched your search
@@ -80,6 +80,24 @@ CSFML_GRAPHICS_API sfColor sfColor_fromRGB(sfUint8 red, sfUint8 green, sfUint8 b
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_GRAPHICS_API sfColor sfColor_fromRGBA(sfUint8 red, sfUint8 green, sfUint8 blue, sfUint8 alpha);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Construct the color from 32-bit unsigned integer
|
||||
///
|
||||
/// \param color Number containing the RGBA components (in that order)
|
||||
///
|
||||
/// \return sfColor constructed from the 32-bit unsigned integer
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_GRAPHICS_API sfColor sfColor_fromInteger(sfUint32 color);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Convert a color to a 32-bit unsigned integer
|
||||
///
|
||||
/// \return Color represented as a 32-bit unsigned integer
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_GRAPHICS_API sfUint32 sfColor_toInteger(sfColor color);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Add two colors
|
||||
///
|
||||
|
||||
@@ -63,6 +63,25 @@ sfColor sfColor_fromRGBA(sfUint8 red, sfUint8 green, sfUint8 blue, sfUint8 alpha
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfColor sfColor_fromInteger(sfUint32 color)
|
||||
{
|
||||
sfUint8 red = (color & 0xff000000) >> 24;
|
||||
sfUint8 green = (color & 0x00ff0000) >> 16;
|
||||
sfUint8 blue = (color & 0x0000ff00) >> 8;
|
||||
sfUint8 alpha = (color & 0x000000ff) >> 0;
|
||||
|
||||
return sfColor_fromRGBA(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfUint32 sfColor_toInteger(sfColor color)
|
||||
{
|
||||
return (color.r << 24) | (color.g << 16) | (color.b << 8) | color.a;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfColor sfColor_add(sfColor color1, sfColor color2)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user