From 1f2bc148fee145483722e74c6cf6185f8b435af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Wed, 11 Feb 2015 12:09:33 +0100 Subject: [PATCH] Implemented sf::Color::toInteger() to complement the new sf::Color constructor. --- include/SFML/Graphics/Color.hpp | 12 ++++++++++-- src/SFML/Graphics/Color.cpp | 7 +++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/SFML/Graphics/Color.hpp b/include/SFML/Graphics/Color.hpp index 1dd152d86..8b3fd7770 100644 --- a/include/SFML/Graphics/Color.hpp +++ b/include/SFML/Graphics/Color.hpp @@ -62,12 +62,20 @@ public: 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) /// //////////////////////////////////////////////////////////// - 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 diff --git a/src/SFML/Graphics/Color.cpp b/src/SFML/Graphics/Color.cpp index 0f483c3aa..5d25ea74d 100644 --- a/src/SFML/Graphics/Color.cpp +++ b/src/SFML/Graphics/Color.cpp @@ -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) {