Rect

Utility class for manipulating 2D axis aligned rectangles.

A rectangle is defined by its top-left corner and its size.

It is a very simple class defined for convenience, so its member variables (left, top, width and height) are public and can be accessed directly, just like the vector classes (Vector2 and Vector3).

To keep things simple, Rect doesn't define functions to emulate the properties that are not directly members (such as right, bottom, center, etc.), it rather only provides intersection functions.

Rect uses the usual rules for its boundaries: - The let and top edges are included in the rectangle's area - The right (left + width) and bottom (top + height) edges are excluded from the rectangle's area

This means that IntRect(0, 0, 1, 1) and IntRect(1, 1, 1, 1) don't intersect.

Rect is a template and may be used with any numeric type, but for simplicity the instanciations used by SFML are typedefed: - Rect!(int) is IntRect - Rect!(float) is FloatRect

So that you don't have to care about the template syntax.

Constructors

this
this(T rectLeft, T rectTop, T rectWidth, T rectHeight)
Undocumented in source.
this
this(Vector2!(T) position, Vector2!(T) size)
Undocumented in source.

Members

Functions

contains
bool contains(E X, E Y)

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

contains
bool contains(Vector2!(E) point)

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

intersects
bool intersects(Rect!(E) rectangle)

Check the intersection between two rectangles.

intersects
bool intersects(Rect!(E) rectangle, Rect!(O) intersection)

Check the intersection between two rectangles.

opEquals
bool opEquals(Rect!(E) otherRect)
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

height
T height;

HEight of the rectangle.

left
T left;

Left coordinate of the rectangle.

top
T top;

Top coordinate of the rectangle.

width
T width;

Width of the rectangle.

See Also

Meta

Authors

Laurent Gomila, Jeremy DeHaan