A Rectangle specifies an area that is enclosed by it's top-left point (x, y), its width, and its height. It should not be confused with a rectangular path, it is not an item.
Constructors
- Parameters:
- x: Number — optional
- y: Number — optional
- width: Number — optional
- height: Number — optional
- Returns:
- Rectangle
Creates a rectangle object from the passed points. These do not necessarily need to be the top left and bottom right corners, the constructor figures out how to fit a rectangle between them.
- Parameters:
- point1: Point — The first point defining the rectangle
- point2: Point — The second point defining the rectangle
- Returns:
- Rectangle
Properties
The y position of the rectangle. This is the top coordinate if in the top-down coordinate system, bottom otherwise. See script.coordinateSystem for more information.
- Returns:
- Number
Side Positions
The position of the left hand side of the rectangle. Note that this doesn't move the whole rectangle; the right hand side stays where it was.
- Returns:
- Number
The top coordinate of the rectangle. Note that this doesn't move the whole rectangle: the bottom won't move.
- Returns:
- Number
The position of the right hand side of the rectangle. Note that this doesn't move the whole rectangle; the left hand side stays where it was.
- Returns:
- Number
The bottom coordinate of the rectangle. Note that this doesn't move the whole rectangle: the top won't move.
- Returns:
- Number
Corner and Center Point Positions
The bottom left point of the rectangle.
- Returns:
- Point
The bottom right point of the rectangle.
- Returns:
- Point
- Returns:
- Point
- Returns:
- Point
- Returns:
- Point
Functions
Geometric Tests
Tests if the specified point is inside the boundary of the rectangle.
- Parameters:
- point: Point — the specified point
- Returns:
- Boolean — true if the point is inside the rectangle's boundary, false otherwise
Tests if the interior of the rectangle entirely contains the specified rectangle.
- Parameters:
- rect: Rectangle — The specified rectangle
- Returns:
- Boolean — true if the rectangle entirely contains the specified rectangle, false otherwise
Tests if the interior of this rectangle intersects the interior of another rectangle.
- Parameters:
- rect: Rectangle — the specified rectangle
- Returns:
- Boolean — true if the rectangle and the specified rectangle intersect each other, false otherwise
Boolean Operations
Adds a point to this rectangle. The resulting rectangle is the smallest rectangle that contains both the original rectangle and the specified point.
After adding a point, a call to contains with the added point as an argument does not necessarily return true. The contains method does not return true for points on the right or bottom edges of a rectangle. Therefore, if the added point falls on the left or bottom edge of the enlarged rectangle, contains returns false for that point.
- Parameters:
- point: Point
- Returns:
- Rectangle