class SizeRect

namespace sys.core
class SizeRect

A generic rectangle defined by an origin point and a size.

Constructors

this

this{x: T, y: T, x2: T, y2: T};

Brief

Creates a new rectangle based on four coordinates defining two opposite corners of the rectangle.

Parameters

x first corner left
y first corner top
x2 second corner left
y2 second corner top

FromSize

this FromSize{x: T, y: T, w: T, h: T};

Brief

Creates a new rectangle based on the two coordinates of the first corner and a size given by width and height.

Parameters

x first corner left
y first corner top
w width
h height

Methods

Offset

def Offset(horizontal: T, vertical: T);

Brief

Translates the rectangle by two relative vertical and horizontal amounts.

Parameters

horizontal horizontal translation amount
vertical vertical translation amount

Offseted

func Offseted(horizontal: T, vertical: T): SizeRect;

Brief

Creates a new translated rectangle by two relative vertical and horizontal amounts.

Parameters

horizontal horizontal translation amount
vertical vertical translation amount

Returns

the new rectangle

Inflate

def Inflate(horizontal: T, vertical: T);

Brief

Inflates the rectangle by two relative vertical and horizontal amounts.

Parameters

horizontal horizontal inflation amount
vertical vertical inflation amount

Inflated

func Inflated(horizontal: T, vertical: T): SizeRect;

Brief

Returns a new inflated rectangle by two relative vertical and horizontal amounts.

Parameters

horizontal horizontal inflation amount
vertical vertical inflation amount

Returns

the new rectangle

Normalize

def Normalize();

Brief

Normalizes the rectangle.

A normalized rectangle will have its lower coordinates stored in the origin point and its higher coordinates in the second point:
> X <= X2
> Y <= Y2


Normalized

func Normalized(): SizeRect;

Brief

returns a new normalized rectangle.

A normalized rectangle will have its lower coordinates stored in the origin point and its higher coordinates in the second point:
> X <= X2
> Y <= Y2

Returns

the new rectangle

Contains

func Contains(x: T, y: T): Bool;
func Contains(r: SizeRect): Bool;

Brief

Checks if the rectangle fully contains within its bounds a point defined by `x` and `y` or another rectangle given by `r`.

Parameters

x the left of the point
y the top of the point
r the rectangle

Returns

`true` if the entity is contained within the rectangle

Intersects

func Intersects(r: SizeRect): Bool;

Brief

Checks if the rectangle intersects another rectangle.

Parameters

r the rectangle

Returns

`true` if there is an intersection

Properties

X2

property X2: T

Brief

Gets and sets the left of the second corner of the rectangle.


Y2

property Y2: T

Brief

Gets and sets the top of the second corner of the rectangle.


IsEmpty

property IsEmpty: Bool; get;

Brief

Returns true if the rectangle is empty: it has both its `Width` and `Height` equal to zero.

Variables

X

val X: T;

Brief

Gets and sets the left of the first corner of the rectangle.


Y

val Y: T;

Brief

Gets and sets the top of the first corner of the rectangle.


Width

val Width: T;

Brief

Gets and sets the left of width of the rectangle.


Height

val Height: T;

Brief

Gets and sets the left of height of the rectangle.