Optionalx: numberThe X coordinate of the top left corner of the Rectangle. Default 0.
Optionaly: numberThe Y coordinate of the top left corner of the Rectangle. Default 0.
Optionalwidth: numberThe width of the Rectangle. Default 0.
Optionalheight: numberThe height of the Rectangle. Default 0.
The sum of the y and height properties. Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property.
The x coordinate of the center of the Rectangle.
The y coordinate of the center of the Rectangle.
The height of the Rectangle, i.e. the distance between its top side (defined by y) and its bottom side.
The x coordinate of the left of the Rectangle. Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property.
The sum of the x and width properties. Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property.
The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. However it does affect the height property, whereas changing the y value does not affect the height property.
ReadonlytypeThe geometry constant type of this object: GEOM_CONST.RECTANGLE.
Used for fast type comparisons.
The width of the Rectangle, i.e. the distance between its left side (defined by x) and its right side.
The X coordinate of the top left corner of the Rectangle.
The Y coordinate of the top left corner of the Rectangle.
Checks if the given point is inside the Rectangle's bounds.
The X coordinate of the point to check.
The Y coordinate of the point to check.
Calculates the coordinates of a point at a certain position on the Rectangle's perimeter.
The position is a fraction between 0 and 1 which defines how far into the perimeter the point is.
A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side.
The normalized distance into the Rectangle's perimeter to return.
Optionaloutput: OA Vector2 instance to update with the x and y coordinates of the point.
Returns an array of points from the perimeter of the Rectangle, each spaced out based on the quantity or step required.
The number of points to return. Set to false or 0 to return an arbitrary number of points (perimeter / stepRate) evenly spaced around the Rectangle based on the stepRate.
OptionalstepRate: numberIf quantity is 0, determines the normalized distance between each returned point.
Optionaloutput: OAn array to which to append the points.
Determines if the Rectangle is empty. A Rectangle is empty if its width or height is less than or equal to 0.
Resets the position, width, and height of the Rectangle to 0.
Sets the position of the Rectangle.
The X coordinate of the top left corner of the Rectangle.
Optionaly: numberThe Y coordinate of the top left corner of the Rectangle. Default x.
Sets the width and height of the Rectangle.
The width to set the Rectangle to.
Optionalheight: numberThe height to set the Rectangle to. Default width.
Sets the position, width, and height of the Rectangle.
The X coordinate of the top left corner of the Rectangle.
The Y coordinate of the top left corner of the Rectangle.
The width of the Rectangle.
The height of the Rectangle.
StaticAreaStaticCeilStaticCeilStaticCenterStaticCloneStaticContainsStaticContainsStaticContainsStaticCopyStaticDecomposeCreate an array of points for each corner of a Rectangle If an array is specified, each point object will be added to the end of the array, otherwise a new array will be created.
StaticEqualsStaticFitAdjusts the target rectangle, changing its width, height and position, so that it fits inside the area of the source rectangle, while maintaining its original aspect ratio.
Unlike the FitOutside function, there may be some space inside the source area not covered.
StaticFitAdjusts the target rectangle, changing its width, height and position, so that it fully covers the area of the source rectangle, while maintaining its original aspect ratio.
Unlike the FitInside function, the target rectangle may extend further out than the source.
StaticFloorStaticFloorStaticFromConstructs new Rectangle or repositions and resizes an existing Rectangle so that all of the given points are on or within its bounds.
The points parameter is an array of Point-like objects:
const points = [
[100, 200],
[200, 400],
{ x: 30, y: 60 }
]
An array of points (either arrays with two elements corresponding to the X and Y coordinate or an object with public x and y properties) which should be surrounded by the Rectangle.
Optionalout: OOptional Rectangle to adjust.
StaticFromCreate the smallest Rectangle containing two coordinate pairs.
The X coordinate of the first point.
The Y coordinate of the first point.
The X coordinate of the second point.
The Y coordinate of the second point.
Optionalout: OOptional Rectangle to adjust.
StaticGetStaticGetStaticGetCalculates the coordinates of a point at a certain position on the Rectangle's perimeter.
The position is a fraction between 0 and 1 which defines how far into the perimeter the point is.
A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side.
StaticGetReturn an array of Vector2 points from the perimeter of the rectangle, each spaced out based on the quantity or step required.
The Rectangle object to get the points from.
Step between points. Used to calculate the number of points to return when quantity is falsey. Ignored if quantity is positive.
The number of evenly spaced points from the rectangles perimeter to return. If falsey, step param will be used to calculate the number of points.
Optionalout: OAn optional array to store the points in.
StaticGetReturns the size of the Rectangle, expressed as a Vector2 object.
With the value of the width as the x property and the height as the y property.
StaticInflateIncreases the size of a Rectangle by a specified amount.
The center of the Rectangle stays the same. The amounts are added to each side, so the actual increase in width or height is two times bigger than the respective argument.
The Rectangle to inflate.
How many pixels the left and the right side should be moved by horizontally.
How many pixels the top and the bottom side should be moved by vertically.
StaticIntersectionTakes two Rectangles and first checks to see if they intersect.
If they intersect it will return the area of intersection in the out Rectangle.
If they do not intersect, the out Rectangle will have a width and height of zero.
StaticMarchingReturns an array of Vector2 points from the perimeter of the Rectangle, where each point is spaced out based
on either the step value, or the quantity.
The Rectangle to get the perimeter points from.
Optionalstep: numberThe distance between each point of the perimeter. Set to null if you wish to use the quantity parameter instead.
Optionalquantity: numberThe total number of points to return. The step is then calculated based on the length of the Rectangle, divided by this value.
Optionalout: OAn array in which the perimeter points will be stored. If not given, a new array instance is created.
StaticMergeMerges a Rectangle with a list of points by repositioning and/or resizing it such that all points are located on or within its bounds.
StaticMergeMerges the source rectangle into the target rectangle and returns the target. Neither rectangle should have a negative width or height.
StaticMergeMerges a Rectangle with a point by repositioning and/or resizing it so that the point is on or within its bounds.
The Rectangle which should be merged and modified.
The X coordinate of the point which should be merged.
The Y coordinate of the point which should be merged.
StaticOffsetStaticOffsetStaticOverlapsStaticPerimeterStaticPerimeterReturns a Point from the perimeter of a Rectangle based on the given angle.
StaticRandomStaticRandomCalculates a random point that lies within the outer Rectangle, but outside of the inner Rectangle.
The inner Rectangle must be fully contained within the outer rectangle.
StaticSameStaticScaleScales the width and height of this Rectangle by the given amounts.
The Rectangle object that will be scaled by the specified amount(s).
The factor by which to scale the rectangle horizontally.
The amount by which to scale the rectangle vertically. If this is not specified, the rectangle will be scaled by the factor x in both directions.
StaticUnionCreates a new Rectangle or repositions and/or resizes an existing Rectangle so that it encompasses the two given Rectangles, i.e. calculates their union.
Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height)