Rect

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

Constructors

this
this(T x, T y, T width, T height)

CTor

this
this(Vector2!(T) vec, T width, T height)

CTor

this
this(Rect!U rect)

CTor

this
this(SDL_Rect rect)
Undocumented in source.

Members

Functions

asArray
T[4] asArray()

Returns the coordinates as static array

collapse
void collapse()

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

contains
bool contains(Vector2!(T) vec)

Checks whether this Rect contains the given coordinates.

contains
bool contains(T x, T y)

Checks whether this Rect contains the given coordinates.

getPosition
Vector2!(T) getPosition()

Returns the current position as Vector2

getSize
Vector2!(T) getSize()

Returns the current size as Vector2

getUnion
Rect getUnion(Rect rect)

Returns an union of the given and this Rect.

increase
void increase(T width, T height)

Increase current size.

intersects
bool intersects(Rect rect, Rect* overlap)

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

isCollapsed
bool isCollapsed()

Checks if this Rect is collapsed, which means that the width and/or the height are <= 0. This is a pure and nothrow variant of isEmpty.

isEmpty
bool isEmpty()

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

isZero
bool isZero()

Checks if all corners are zero.

move
void move(T x, T y)

Move the object.

move
void move(Vector2!(T) vec)

Move the object.

opBinary
Rect opBinary(Rect rect)

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

opBinaryRight
bool opBinaryRight(Vector2!(T) vec)

Checks whether this Rect contains the given coordinates.

opCast
Rect!U opCast()

opCast to another Rect type.

opEquals
bool opEquals(Rect rect)

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

set
void set(T x, T y, T w, T h)

The new coordinates <b>and</b> a new size.

setPosition
void setPosition(T x, T y)

Set a new position with coordinates.

setPosition
void setPosition(Vector2!(T) position)

Set a new position with a vector.

setSize
void setSize(T width, T height)

Replace current size.

transferTo
void transferTo(SDL_Rect* rect)

Transfer the internal data to the SDL_Rect.

Static functions

enclosePoints
Rect enclosePoints(Vector2!(T)[] points)

Use this function to calculate a minimal rectangle enclosing a set of points.

Variables

height
T height;

and the height

width
T width;

The width

x
T x;

The x

y
T y;

and y coordinates

Meta

Authors

rschuett