Rectangle

An axis-aligned rectangle made of some numeric type

Constructors

this
this(in float x, in float y, in float width, in float height)

Create a rectangle with the given dimension

this
this(in float width, in float height)

Create a rectangle at 0, 0 with a given size

this
this(in Vector top, in Vector dimension)

Create a rectangle with a given top left and a given size

Members

Functions

constrain
Rectangle constrain(in Rectangle outer)

Move the rectangle so it is entirely contained with another

contains
bool contains(in Vector v)

Checks if a point falls within the rectangle

overlaps
bool overlaps(in Rectangle b)

Check if any of the area bounded by this rectangle is bounded by another

overlaps
bool overlaps(in Circle c)

Check if any of the area bounded by this rectangle is bounded by a circle

set
void set(float newX, float newY, float newWidth, float newHeight)

Set the rectangle's dimensions

translate
Rectangle translate(in Vector vec)

Translate the rectangle by a vector

Variables

size
Vector size;

floathe width and height of the rectangle

topLeft
Vector topLeft;

floathe top left of the rectangle

Meta