Skip to main content

Rect

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

Members

Properties

NameDescription
Rect.centerThe position of the center of the rectangle.
Rect.heightThe height of the rectangle, measured from the Y position.
Rect.maxThe position of the maximum corner of the rectangle.
Rect.minThe position of the minimum corner of the rectangle.
Rect.positionThe X and Y position of the rectangle.
Rect.sizeThe width and height of the rectangle.
Rect.widthThe width of the rectangle, measured from the X position.
Rect.xThe X coordinate of the rectangle.
Rect.xMaxThe maximum X coordinate of the rectangle.
Rect.xMinThe minimum X coordinate of the rectangle.
Rect.yThe Y coordinate of the rectangle.
Rect.yMaxThe maximum Y coordinate of the rectangle.
Rect.yMinThe minimum Y coordinate of the rectangle.

Static Properties

NameDescription
Rect.zeroShorthand for writing new Rect(0,0,0,0).

Constructor

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

Methods

NameDescription
Rect.Contains(point)Returns true if the x and y components of point is a point inside this rectangle.
Rect.Contains(point)Returns true if the x and y components of point is a point inside this rectangle.
Rect.Contains(point, allowInverse)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)Returns true if the other rectangle overlaps this one.
Rect.Overlaps(other, allowInverse)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)Set components of an existing Rect.

Static Methods

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

Operators

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