Added getPosition() and getSize() to sf::Rect<T>.

This commit is contained in:
Stefan Schindler 2016-01-22 21:30:54 +01:00 committed by Lukas Dürrenberger
parent 27a4c83ebc
commit ca21695521
2 changed files with 32 additions and 0 deletions

View File

@ -151,6 +151,26 @@ public:
////////////////////////////////////////////////////////////
bool intersects(const Rect<T>& rectangle, Rect<T>& intersection) const;
////////////////////////////////////////////////////////////
/// \brief Get the position of the rectangle's top-left corner
///
/// \return Position of rectangle
///
/// \see getSize
///
////////////////////////////////////////////////////////////
sf::Vector2<T> getPosition() const;
////////////////////////////////////////////////////////////
/// \brief Get the size of the rectangle
///
/// \return Size of rectangle
///
/// \see getPosition
///
////////////////////////////////////////////////////////////
sf::Vector2<T> getSize() const;
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -141,6 +141,18 @@ bool Rect<T>::intersects(const Rect<T>& rectangle, Rect<T>& intersection) const
}
}
template <typename T>
sf::Vector2<T> Rect<T>::getPosition() const
{
return sf::Vector2<T>(left, top);
}
template <typename T>
sf::Vector2<T> Rect<T>::getSize() const
{
return sf::Vector2<T>(width, height);
}
////////////////////////////////////////////////////////////
template <typename T>