Rect

Rect defines a rectangle structure that contains the left upper corner and the width/height.

Constructors

this
this(int x, int y, uint width, uint height)

CTor

Members

Enums

Edge
enum Edge

The edges of the Rectangle

Functions

collapse
void collapse()

Collapse this Rect. Means that the size is set to 0.

contains
bool contains(const Vector2i vec)

Checks whether this Rect contains the given coordinates.

contains
bool contains(int x, int y)

Checks whether this Rect contains the given coordinates.

getCenter
Vector2i getCenter()

Returns the center position of this Rect

getEdgePosition
Vector2i getEdgePosition(Edge edge)

Returns the position of the given Edge on this Rect.

getPosition
Vector2i getPosition()

Returns the current position as Vector2

getSize
Size getSize()

Returns the current size as Vector2

getUnion
Rect getUnion(const Rect rect)

Returns an union of the given and this Rect.

increase
void increase(int width, int height)

Increase current size.

intersects
bool intersects(const Rect rect, Rect* overlap = null)

Checks whether this Rect intersects with an other. If, and the parameter 'overlap' isn't null, the colliding rectangle is stored there.

isEmpty
bool isEmpty()

Checks if this Rect is empty (if it's collapsed) with SDL_RectEmpty.

move
void move(const Vector2i vec)

Move the object.

move
void move(int x, int y)

Move the object.

opBinary
Rect opBinary(const Rect rect)

Supported operations: +, -, *, /, %

opEquals
bool opEquals(const Rect rect)

opEquals: compares two rectangles on their coordinates and their size (but not explicit type).

setPosition
void setPosition(int x, int y)

Set a new position with coordinates.

setPosition
void setPosition(const Vector2i position)

Set a new position with a vector.

setSize
void setSize(uint width, uint height)

Replace the current size.

setSize
void setSize(const Size size)

Replace the current size.

Variables

height
uint height;

The height

width
uint width;

The width

x
int x;

The x coordinate

y
int y;

The y coordinates

Meta

Authors

Randy Schuett (rswhite4@googlemail.com)