From 88ec48cb8578ce9f6bf79cdd0e2b4b746af679be Mon Sep 17 00:00:00 2001 From: FRex Date: Fri, 10 Oct 2014 17:34:55 +0200 Subject: [PATCH] Added a new constructor that takes single Uint32 to Color --- include/SFML/Graphics/Color.hpp | 8 ++++++++ src/SFML/Graphics/Color.cpp | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/SFML/Graphics/Color.hpp b/include/SFML/Graphics/Color.hpp index 8c81e3ce..1dd152d8 100644 --- a/include/SFML/Graphics/Color.hpp +++ b/include/SFML/Graphics/Color.hpp @@ -61,6 +61,14 @@ public: //////////////////////////////////////////////////////////// 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 //////////////////////////////////////////////////////////// diff --git a/src/SFML/Graphics/Color.cpp b/src/SFML/Graphics/Color.cpp index 00d215a9..0f483c3a 100644 --- a/src/SFML/Graphics/Color.cpp +++ b/src/SFML/Graphics/Color.cpp @@ -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) {