sf::Rect< T > Class Template Reference

Rect is an utility class for manipulating rectangles. More...

#include <Rect.hpp>

List of all members.

Public Member Functions

 Rect ()
 Default constructor.
 Rect (T left, T top, T right, T bottom)
 Construct the rectangle from its coordinates.
Vector2< T > GetSize () const
 Get the size of the rectangle.
Vector2< T > GetCenter () const
 Get the center of the rectangle.
void Offset (T offsetX, T offsetY)
 Move the whole rectangle by the given offset.
void Offset (const Vector2< T > &offset)
 Move the whole rectangle by the given offset.
bool Contains (T x, T y) const
 Check if a point is inside the rectangle's area.
bool Contains (const Vector2< T > &point) const
 Check if a point is inside the rectangle's area.
bool Intersects (const Rect< T > &rectangle) const
 Check intersection between two rectangles.
bool Intersects (const Rect< T > &rectangle, Rect< T > &intersection) const
 Check intersection between two rectangles and return the resulting rectangle.

Public Attributes

Left
 Left coordinate of the rectangle.
Top
 Top coordinate of the rectangle.
Right
 Right coordinate of the rectangle.
Bottom
 Bottom coordinate of the rectangle.

Detailed Description

template<typename T>
class sf::Rect< T >

Rect is an utility class for manipulating rectangles.

Template parameter defines the type of coordinates (integer, float, ...)

Definition at line 42 of file Rect.hpp.


Constructor & Destructor Documentation

template<typename T>
sf::Rect< T >::Rect (  ) 

Default constructor.

template<typename T>
sf::Rect< T >::Rect ( left,
top,
right,
bottom 
)

Construct the rectangle from its coordinates.

Parameters:
left : Left coordinate of the rectangle
top : Top coordinate of the rectangle
right : Right coordinate of the rectangle
bottom : Bottom coordinate of the rectangle

Member Function Documentation

template<typename T>
bool sf::Rect< T >::Contains ( const Vector2< T > &  point  )  const

Check if a point is inside the rectangle's area.

Parameters:
point : Point to test
Returns:
True if the point is inside
template<typename T>
bool sf::Rect< T >::Contains ( x,
y 
) const

Check if a point is inside the rectangle's area.

Parameters:
x : X coordinate of the point to test
y : Y coordinate of the point to test
Returns:
True if the point is inside
template<typename T>
Vector2<T> sf::Rect< T >::GetCenter (  )  const

Get the center of the rectangle.

Returns:
Center of rectangle
template<typename T>
Vector2<T> sf::Rect< T >::GetSize (  )  const

Get the size of the rectangle.

Returns:
Size of rectangle
template<typename T>
bool sf::Rect< T >::Intersects ( const Rect< T > &  rectangle,
Rect< T > &  intersection 
) const

Check intersection between two rectangles and return the resulting rectangle.

Parameters:
rectangle : Rectangle to test
intersection : Rectangle to be filled with the intersection of both rectangles
Returns:
True if rectangles overlap
template<typename T>
bool sf::Rect< T >::Intersects ( const Rect< T > &  rectangle  )  const

Check intersection between two rectangles.

Parameters:
rectangle : Rectangle to test
Returns:
True if rectangles overlap
template<typename T>
void sf::Rect< T >::Offset ( const Vector2< T > &  offset  ) 

Move the whole rectangle by the given offset.

Parameters:
offset : Offset to apply to the current position
template<typename T>
void sf::Rect< T >::Offset ( offsetX,
offsetY 
)

Move the whole rectangle by the given offset.

Parameters:
offsetX : Horizontal offset
offsetY : Vertical offset

Member Data Documentation

template<typename T>
T sf::Rect< T >::Bottom

Bottom coordinate of the rectangle.

Definition at line 145 of file Rect.hpp.

template<typename T>
T sf::Rect< T >::Left

Left coordinate of the rectangle.

Definition at line 142 of file Rect.hpp.

template<typename T>
T sf::Rect< T >::Right

Right coordinate of the rectangle.

Definition at line 144 of file Rect.hpp.

template<typename T>
T sf::Rect< T >::Top

Top coordinate of the rectangle.

Definition at line 143 of file Rect.hpp.


The documentation for this class was generated from the following file: