FRect

D struct that wraps SDL_FRect (from SDL 2.0.10) representing a rectangle of floating point 2D coordinate and dimension

dsdl2.FRect stores floating point x and y coordinate points, as well as width and height which specifies the rectangle's dimension. x and y symbolize the top-left coordinate of the rectangle, and the width and height extend to the positive plane of both axes.

Constructors

this
this()
Undocumented in source.
this
this(SDL_FRect sdlFRect)

Constructs a dsdl2.FRect from a vanilla SDL_FRect from bindbc-sdl

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

Constructs a dsdl2.FRect by feeding in the x, y, width, and height of the rectangle

this
this(FPoint point, float width, float height)

Constructs a dsdl2.FRect by feeding in a dsdl2.FPoint as the xy, then width and height of the rectangle

this
this(Rect rect)

Constructs a dsdl2.FRect from a dsdl2.Rect

Members

Functions

empty
bool empty()

Wraps SDL_FRectEmpty (from SDL 2.0.22) which checks if the dsdl2.FRect is an empty rectangle

hasIntersection
bool hasIntersection(FRect rect)

Wraps SDL_HasIntersectionF (from SDL 2.0.22) which sees whether two dsdl2.FRects intersect each other

hasLineIntersection
bool hasLineIntersection(FPoint[2] line)

Wraps SDL_IntersectFRectAndLine (from SDL 2.0.22) which sees whether a line intersects with the dsdl2.FRect

height
inout(float) height()

Proxy to the height of the dsdl2.FRect

intersectLine
Nullable!(FPoint[2]) intersectLine(FPoint[2] line)

Wraps SDL_IntersectFRectAndLine (from SDL 2.0.22) which attempts to clip a line segment in the boundaries of the dsdl2.FRect

intersectRect
Nullable!FRect intersectRect(FRect other)

Wraps SDL_IntersectFRect (from SDL 2.0.22) which attempts to get the rectangle of intersection between two dsdl2.FRects

opBinary
FRect opBinary(FPoint offset)

Binary operation overload template to move rectangle's position by an offset as a dsdl2.FPoint

opOpAssign
inout(FPoint) opOpAssign(FPoint offset)

Operator assignment overload template to move rectangle's position in-place by an offset as a dsdl2.FPoint

point
inout(FPoint) point()

Proxy to the dsdl2.FPoint containing the x and y value of the dsdl2.FRect

pointInRect
bool pointInRect(FPoint point)

Wraps SDL_PointInFRect (from SDL 2.0.22) which sees whether the coordinate of a dsdl2.FPoint is inside the dsdl2.FRect

size
inout(float[2]) size()

Proxy to the size array containing the width and height of the dsdl2.FRect

toString
string toString()

Formats the dsdl2.FRect into its construction representation: "dsdl2.FRect(<x>, <y>, <w>, <h>)"

unify
FRect unify(FRect other)

Wraps SDL_UnionFRect which creates a dsdl2.FRect (from SDL 2.0.22) of the minimum size to enclose two given dsdl2.FRects

width
inout(float) width()

Proxy to the width of the dsdl2.FRect

x
inout(float) x()

Proxy to the X value of the dsdl2.FRect

y
inout(float) y()

Proxy to the Y value of the dsdl2.FRect

Variables

sdlFRect
SDL_FRect sdlFRect;

Internal SDL_FRect struct

Examples

auto rect1 = dsdl2.FRect(-2.0, -2.0, 3.0, 3.0);
auto rect2 = dsdl2.FRect(-1.0, -1.0, 3.0, 3.0);

assert(rect1.hasIntersection(rect2));
assert(rect1.intersectRect(rect2).get == dsdl2.FRect(-1.0, -1.0, 2.0, 2.0));

Meta