Skip to content

API > Rect


Rect⚓︎

A 2D Rectangle defined by X and Y position, width and height.

Members⚓︎

Properties⚓︎

Name Description
Rect.centerProperty The position of the center of the rectangle.
Rect.heightProperty The height of the rectangle, measured from the Y position.
Rect.maxProperty The position of the maximum corner of the rectangle.
Rect.minProperty The position of the minimum corner of the rectangle.
Rect.positionProperty The X and Y position of the rectangle.
Rect.sizeProperty The width and height of the rectangle.
Rect.widthProperty The width of the rectangle, measured from the X position.
Rect.xProperty The X coordinate of the rectangle.
Rect.xMaxProperty The maximum X coordinate of the rectangle.
Rect.xMinProperty The minimum X coordinate of the rectangle.
Rect.yProperty The Y coordinate of the rectangle.
Rect.yMaxProperty The maximum Y coordinate of the rectangle.
Rect.yMinProperty The minimum Y coordinate of the rectangle.

Static Properties⚓︎

Name Description
Rect.zero Static fieldPropertyReadonly Property Shorthand for writing new Rect(0,0,0,0).

Constructor⚓︎

Name Description
Rect(x, y, width, height)Constructor Creates a new rectangle.
Rect(position, size)Constructor Creates a rectangle given a size and position.

Methods⚓︎

Name Description
Rect.Contains(point) Method Returns true if the x and y components of point is a point inside this rectangle.
Rect.Contains(point) Method Returns true if the x and y components of point is a point inside this rectangle.
Rect.Contains(point, allowInverse) Method Returns true if the x and y components of point is a point inside this rectangle. If allowInverse is present and true, the width and height of the Rect are allowed to take negative values (ie, the min value is greater than the max), and the test will still work.
Rect.Overlaps(other) Method Returns true if the other rectangle overlaps this one.
Rect.Overlaps(other, allowInverse) Method Returns true if the other rectangle overlaps this one. If allowInverse is present and true, the widths and heights of the Rects are allowed to take negative values (ie, the min value is greater than the max), and the test will still work.
Rect.Set(x, y, width, height) Method Set components of an existing Rect.

Static Methods⚓︎

Name Description
Rect.MinMaxRect(xmin, ymin, xmax, ymax) Static fieldMethod Creates a rectangle from min/max coordinate values.
Rect.NormalizedToPoint(rectangle , normalizedRectCoordinates) Static fieldMethod Returns a point inside a rectangle, given normalized coordinates.
Rect.PointToNormalized(rectangle, point) Static fieldMethod Returns the normalized coordinates cooresponding the the point.

Operators⚓︎

Name Description
Operator (Rect==Rect)Operator Returns true if the rectangles are the same.