namespace sys.core
class SizeRect
A generic rectangle defined by an origin point and a size.
this{x: T, y: T, x2: T, y2: T};
Creates a new rectangle based on four coordinates defining two opposite corners of the rectangle.
x | first corner left |
---|---|
y | first corner top |
x2 | second corner left |
y2 | second corner top |
this FromSize{x: T, y: T, w: T, h: T};
Creates a new rectangle based on the two coordinates of the first corner and a size given by width and height.
x | first corner left |
---|---|
y | first corner top |
w | width |
h | height |
def Offset(horizontal: T, vertical: T);
Translates the rectangle by two relative vertical and horizontal amounts.
horizontal | horizontal translation amount |
---|---|
vertical | vertical translation amount |
func Offseted(horizontal: T, vertical: T): SizeRect;
Creates a new translated rectangle by two relative vertical and horizontal amounts.
horizontal | horizontal translation amount |
---|---|
vertical | vertical translation amount |
the new rectangle
def Inflate(horizontal: T, vertical: T);
Inflates the rectangle by two relative vertical and horizontal amounts.
horizontal | horizontal inflation amount |
---|---|
vertical | vertical inflation amount |
func Inflated(horizontal: T, vertical: T): SizeRect;
Returns a new inflated rectangle by two relative vertical and horizontal amounts.
horizontal | horizontal inflation amount |
---|---|
vertical | vertical inflation amount |
the new rectangle
def Normalize();
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
func Normalized(): SizeRect;
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
the new rectangle
func Contains(x: T, y: T): Bool;
func Contains(r: SizeRect): Bool;
Checks if the rectangle fully contains within its bounds a point defined by `x` and `y` or another rectangle given by `r`.
x | the left of the point |
---|---|
y | the top of the point |
r | the rectangle |
`true` if the entity is contained within the rectangle
func Intersects(r: SizeRect): Bool;
Checks if the rectangle intersects another rectangle.
r | the rectangle |
---|
`true` if there is an intersection
property X2: T
Gets and sets the left of the second corner of the rectangle.
property Y2: T
Gets and sets the top of the second corner of the rectangle.
property IsEmpty: Bool; get;
Returns true if the rectangle is empty: it has both its `Width` and `Height` equal to zero.
val X: T;
Gets and sets the left of the first corner of the rectangle.
val Y: T;
Gets and sets the top of the first corner of the rectangle.
val Width: T;
Gets and sets the left of width of the rectangle.
val Height: T;
Gets and sets the left of height of the rectangle.