Skip to content

TSdlRect

A rectangle, with the origin at the upper left (using integers).

Definition

Unit: Neslib.Sdl3.Video

type TSdlRect = record ... end;

Fields

Name Description
H
W
X
Y

Properties

Name Description
IsEmpty Whether the rectangle has no area.

Constructors

Name Description
Create(TRect) Create from a TRect.
Create(Integer, Integer, Integer, Integer) Create from X, Y, W and H values.

Operators

Name Description
Equal Determine whether two rectangles are equal.
NotEqual Determine whether two rectangles are not equal.

Methods

Name Description
ContainsPoint Determine whether a point resides inside the rectangle.
Init(TRect) Initialize from a TRect.
Init(Integer, Integer, Integer, Integer) Initialize from X, Y, W and H values.
InitFromEnclosingPoints(TSdlPoint[], PSdlRect) Calculate a minimal rectangle enclosing a set of points.
InitFromEnclosingPoints(TArray<TSdlPoint>, PSdlRect) Calculate a minimal rectangle enclosing a set of points.
Intersection Calculate the intersection of two rectangles.
Intersects Determine whether two rectangles intersect.
LineIntersection(TSdlPoint, TSdlPoint) Calculate the intersection of this rectangle and line segment.
LineIntersection(Integer, Integer, Integer, Integer) Calculate the intersection of this rectangle and line segment.
Union Calculate the union of two rectangles.

Field Descriptions

H

var H: Integer

Type: Integer


W

var W: Integer

Type: Integer


X

var X: Integer

Type: Integer


Y

var Y: Integer

Type: Integer


Property Descriptions

IsEmpty

Whether the rectangle has no area.

A rectangle is considered "empty" for this function if it's width and/or height are <whether the rectangle has no area.

a rectangle is considered "empty" for this function if it's width and/or height are />True if the rectangle is "empty", False otherwise.It is safe to use this property from any thread.

property IsEmpty: Boolean read GetIsEmpty

Type: Boolean


Constructor Descriptions

Create

Create from a TRect.

constructor Create(const ARect: TRect); overload

Parameters

ARect: TRect : The TRect.

Remarks

It is safe to call this constructor from any thread.


Create

Create from X, Y, W and H values.

constructor Create(const AX, AY, AW, AH: Integer); overload

Parameters

AX: Integer : The X value.

AY: Integer : The Y value.

AW: Integer : The width.

AH: Integer : The height.

Remarks

It is safe to call this constructor from any thread.


Operator Descriptions

Equal(TSdlRect, TSdlRect)

Determine whether two rectangles are equal.

class operator Equal(const ALeft, ARight: TSdlRect): Boolean; inline; static

Parameters

ALeft: TSdlRect

ARight: TSdlRect

Returns

Boolean

Remarks

It is safe to call this operator from any thread.


NotEqual(TSdlRect, TSdlRect)

Determine whether two rectangles are not equal.

class operator NotEqual(const ALeft, ARight: TSdlRect): Boolean; inline; static

Parameters

ALeft: TSdlRect

ARight: TSdlRect

Returns

Boolean

Remarks

It is safe to call this operator from any thread.


Method Descriptions

ContainsPoint(TSdlPoint)

Determine whether a point resides inside the rectangle.

A point is considered part of a rectangle if APP's x and y coordinates are >= to the rectangle's top left corner, and <determine whether a point resides inside the rectangle.

a point is considered part of a rectangle if app's x and y coordinates are >= to the rectangle's top left corner, and >rectangle's X+W and Y+H. So a 1x1 rectangle considers point (0, 0) as "inside" and (0, 1) as not. </determine whether a point resides inside the rectangle.

a point is considered part of a rectangle if app's x and y coordinates are >= to the rectangle's top left corner, and >The point to test.True if AP is contained by this rectangle, False otherwise.It is safe to call this method from any thread.

function ContainsPoint(const AP: TSdlPoint): Boolean; inline

Parameters

AP: TSdlPoint

Returns

Boolean


Init(TRect)

Initialize from a TRect.

procedure Init(const ARect: TRect); overload; inline

Parameters

ARect: TRect : The TRect.

Remarks

It is safe to call this method from any thread.


Init(Integer, Integer, Integer, Integer)

Initialize from X, Y, W and H values.

procedure Init(const AX, AY, AW, AH: Integer); overload; inline

Parameters

AX: Integer : The X value.

AY: Integer : The Y value.

AW: Integer : The width.

AH: Integer : The height.

Remarks

It is safe to call this method from any thread.


InitFromEnclosingPoints(TSdlPoint[], PSdlRect)

Calculate a minimal rectangle enclosing a set of points.

If AClip is not nil then only points inside of the clipping rectangle are considered.

function InitFromEnclosingPoints(const APoints: array of TSdlPoint; const AClip: PSdlRect = nil): Boolean; overload

Parameters

APoints: array of TSdlPoint : An array of points to be enclosed.

AClip: PSdlRect = nil : (Optional) rect used for clipping or nil to enclose all points.

Returns

Boolean: True if any points were enclosed or False if all the points were outside of the clipping rectangle.


InitFromEnclosingPoints(TArray<TSdlPoint>, PSdlRect)

Calculate a minimal rectangle enclosing a set of points.

If AClip is not nil then only points inside of the clipping rectangle are considered.

function InitFromEnclosingPoints(const APoints: TArray<TSdlPoint>; const AClip: PSdlRect = nil): Boolean; overload; inline

Parameters

APoints: TArray<TSdlPoint> : An array of points to be enclosed.

AClip: PSdlRect = nil : (Optional) rect used for clipping or nil to enclose all points.

Returns

Boolean: True if any points were enclosed or False if all the points were outside of the clipping rectangle.


Intersection(TSdlRect, TSdlRect)

Calculate the intersection of two rectangles.

function Intersection(const AOther: TSdlRect; out AIntersection: TSdlRect): Boolean; inline

Parameters

AOther: TSdlRect : The other rectangle.

AIntersection: TSdlRect : Is set to the intersection of this rectangle and AOther.

Returns

Boolean: True if there is an intersection, False otherwise.

See Also


Intersects(TSdlRect)

Determine whether two rectangles intersect.

function Intersects(const AOther: TSdlRect): Boolean; inline

Parameters

AOther: TSdlRect : The other rectangle.

Returns

Boolean: True if there is an intersection, False otherwise.

See Also

Remarks

It is safe to call this method from any thread.


LineIntersection(TSdlPoint, TSdlPoint)

Calculate the intersection of this rectangle and line segment.

This function is used to clip a line segment to a rectangle. A line segment contained entirely within the rectangle or that does not intersect will remain unchanged. A line segment that crosses the rectangle at either or both ends will be clipped to the boundary of the rectangle and the new coordinates saved in AP1 and/or AP2 as necessary.

function LineIntersection(var AP1, AP2: TSdlPoint): Boolean; overload; inline

Parameters

AP1: TSdlPoint : The starting point of the line.

AP2: TSdlPoint : The ending point of the line.

Returns

Boolean: True if there is an intersection, False otherwise.


LineIntersection(Integer, Integer, Integer, Integer)

Calculate the intersection of this rectangle and line segment.

This function is used to clip a line segment to a rectangle. A line segment contained entirely within the rectangle or that does not intersect will remain unchanged. A line segment that crosses the rectangle at either or both ends will be clipped to the boundary of the rectangle and the new coordinates saved in AX1, AY1, AX2, and/or AY2 as necessary.

function LineIntersection(var AX1, AY1, AX2, AY2: Integer): Boolean; overload; inline

Parameters

AX1: Integer : The starting X-coordinate of the line.

AY1: Integer : The starting Y-coordinate of the line.

AX2: Integer : The ending X-coordinate of the line.

AY2: Integer : The ending Y-coordinate of the line.

Returns

Boolean: True if there is an intersection, False otherwise.


Union(TSdlRect, TSdlRect)

Calculate the union of two rectangles.

procedure Union(const AOther: TSdlRect; out AUnion: TSdlRect); inline

Parameters

AOther: TSdlRect : The other rectangle.

AUnion: TSdlRect : Is set to the union this rectangle and AOther.