Struct FRect

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

struct FRect ;

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

NameDescription
this (sdlFRect) Constructs a dsdl2.FRect from a vanilla SDL_FRect from bindbc-sdl
this (x, y, width, height) Constructs a dsdl2.FRect by feeding in the x, y, width, and height of the rectangle
this (point, width, height) Constructs a dsdl2.FRect by feeding in a dsdl2.FPoint as the xy, then width and height of the rectangle
this (rect) Constructs a dsdl2.FRect from a dsdl2.Rect

Fields

NameTypeDescription
sdlFRect sdl.rect.SDL_FRectInternal SDL_FRect struct

Properties

NameTypeDescription
height[get] inout(float)Proxy to the height of the dsdl2.FRect
point[get] inout(FPoint)Proxy to the dsdl2.FPoint containing the x and y value of the dsdl2.FRect
size[get] inout(float[2])Proxy to the size array containing the width and height of the dsdl2.FRect
width[get] inout(float)Proxy to the width of the dsdl2.FRect
x[get] inout(float)Proxy to the X value of the dsdl2.FRect
y[get] inout(float)Proxy to the Y value of the dsdl2.FRect

Methods

NameDescription
empty () Wraps SDL_FRectEmpty (from SDL 2.0.22) which checks if the dsdl2.FRect is an empty rectangle
hasIntersection (rect) Wraps SDL_HasIntersectionF (from SDL 2.0.22) which sees whether two dsdl2.FRects intersect each other
hasLineIntersection (line) Wraps SDL_IntersectFRectAndLine (from SDL 2.0.22) which sees whether a line intersects with the dsdl2.FRect
intersectLine (line) Wraps SDL_IntersectFRectAndLine (from SDL 2.0.22) which attempts to clip a line segment in the boundaries of the dsdl2.FRect
intersectRect (other) Wraps SDL_IntersectFRect (from SDL 2.0.22) which attempts to get the rectangle of intersection between two dsdl2.FRects
opBinary (offset) Binary operation overload template to move rectangle's position by an offset as a dsdl2.FPoint
opOpAssign (offset) Operator assignment overload template to move rectangle's position in-place by an offset as a dsdl2.FPoint
pointInRect (point) Wraps SDL_PointInFRect (from SDL 2.0.22) which sees whether the coordinate of a dsdl2.FPoint is inside the dsdl2.FRect
toString () Formats the dsdl2.FRect into its construction representation: "dsdl2.FRect(<x>, <y>, <w>, <h>)"
unify (other) Wraps SDL_UnionFRect which creates a dsdl2.FRect (from SDL 2.0.22) of the minimum size to enclose two given dsdl2.FRects

Example

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));