From ca21695521c148cb5e06ed9be80abffe3d9019c2 Mon Sep 17 00:00:00 2001 From: Stefan Schindler Date: Fri, 22 Jan 2016 21:30:54 +0100 Subject: [PATCH] Added getPosition() and getSize() to sf::Rect. --- include/SFML/Graphics/Rect.hpp | 20 ++++++++++++++++++++ include/SFML/Graphics/Rect.inl | 12 ++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/SFML/Graphics/Rect.hpp b/include/SFML/Graphics/Rect.hpp index f3c6d3b6d..466db4d07 100644 --- a/include/SFML/Graphics/Rect.hpp +++ b/include/SFML/Graphics/Rect.hpp @@ -151,6 +151,26 @@ public: //////////////////////////////////////////////////////////// bool intersects(const Rect& rectangle, Rect& intersection) const; + //////////////////////////////////////////////////////////// + /// \brief Get the position of the rectangle's top-left corner + /// + /// \return Position of rectangle + /// + /// \see getSize + /// + //////////////////////////////////////////////////////////// + sf::Vector2 getPosition() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the size of the rectangle + /// + /// \return Size of rectangle + /// + /// \see getPosition + /// + //////////////////////////////////////////////////////////// + sf::Vector2 getSize() const; + //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// diff --git a/include/SFML/Graphics/Rect.inl b/include/SFML/Graphics/Rect.inl index ef3fc3459..1aa073dca 100644 --- a/include/SFML/Graphics/Rect.inl +++ b/include/SFML/Graphics/Rect.inl @@ -141,6 +141,18 @@ bool Rect::intersects(const Rect& rectangle, Rect& intersection) const } } +template +sf::Vector2 Rect::getPosition() const +{ + return sf::Vector2(left, top); +} + +template +sf::Vector2 Rect::getSize() const +{ + return sf::Vector2(width, height); +} + //////////////////////////////////////////////////////////// template