Constructor
new Rectangle(xopt, yopt, widthopt, heightopt)
Create a Rectangle
Object.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
x |
Number
|
<optional>
|
0
|
x The X axis coordinates in the upper left corner of the rectangle.
|
y |
Number
|
<optional>
|
0
|
y The Y axis coordinates in the upper left corner of the rectangle.
|
width |
Number
|
<optional>
|
0
|
width Width of rectangle.
|
height |
Number
|
<optional>
|
0
|
height Rectangular height.
|
Member
bottom :Number
The Y axis coordinates of the bottom of this rectangle. The sum of Y and height attributes.
height :Number
Rectangular height.
right :Number
The X axis coordinates on the right of this rectangle. The sum of X and width attributes.
width :Number
Width of rectangle.
x :Number
The X axis coordinates in the upper left corner of the rectangle.
y :Number
The Y axis coordinates in the upper left corner of the rectangle.
Methods
addPoint(x, y) → {Rectangle}
Adds a point to the current rectangle so that the current rectangle is extended to the minimum rectangle containing the current rectangle and this point.
This method modifies the object.
Parameters:
Name |
Type |
Description |
x |
Number
|
X coordinates of points.
|
y |
Number
|
Y coordinates of points.
|
Returns:
-
Type:
-
Rectangle
Return here Rectangle Object.
Return one Rectangle Object, the value of its X, y, width, and height attributes, and the current Rectangle Object corresponding to the same value.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
out |
Rectangle
|
<optional>
|
null
|
out (optional) a rectangular object used to store results. If it is null, a new one is created. Recommendation: reuse objects as much as possible and reduce object creation costs.. Rectangle.TEMP objects are used for object reuse.
|
Returns:
-
Type:
-
Rectangle
Rectangle Object, the value of its X, y, width, and height attributes, and the current Rectangle Object corresponding to the same value.
contains(x, y) → {Boolean}
Determine this Rectangle Does the rectangle in the object definition contain the specified point?.
Parameters:
Name |
Type |
Description |
x |
Number
|
The X axis value of the points (horizontal position).
|
y |
Number
|
The Y axis value of the points (vertical position).
|
Returns:
-
Type:
-
Boolean
If Rectangle Object containing the specified point, and the value is true; otherwise false.
copyFrom(sourceRect) → {Rectangle}
Copy the property value of the source object to this rectangle object.
Parameters:
Name |
Type |
Description |
sourceRect |
Rectangle
|
source Rectangle Object.
|
Returns:
-
Type:
-
Rectangle
Returns the rectangular object itself after the property value has been modified.
equals(rect) → {Boolean}
Detecting incoming Rectangle Is the property of the object current? Rectangle The attributes of the object, x, y, width, and height, are equal in attribute values.
Parameters:
Name |
Type |
Description |
rect |
Rectangle
|
To be compared Rectangle Object.
|
Returns:
-
Type:
-
Boolean
Returns true if the attributes of the judgments are equal, otherwise false is returned.
intersection(rect, outopt) → {Rectangle}
If specified in the rect parameter Rectangle Object and this Rectangle Object intersects, and returns the intersection area as Rectangle Object. If the rectangle does not intersect, this method returns null.
Parameters:
Name |
Type |
Attributes |
Default |
Description |
rect |
Rectangle
|
|
|
The rectangular area to compare.
|
out |
Rectangle
|
<optional>
|
null
|
out (optional) the rectangular area to be output. If it is null, a new one is created. Recommendation: reuse objects as much as possible and reduce object creation costs.
|
Returns:
-
Type:
-
Rectangle
Returns the rectangular region object that intersects.
intersects(rect) → {Boolean}
Determines whether the object specified in the rect parameter is associated with this Rectangle Object intersection. This method checks for the specified Rectangle Object's x, y, width, and height properties to see if it is here Rectangle Object intersection.
Parameters:
Name |
Type |
Description |
rect |
Rectangle
|
Rectangle Object.
|
Returns:
-
Type:
-
Boolean
If the incoming rectangle object intersects this object, the true value is returned, otherwise false is returned.
isEmpty() → {Boolean}
Determine this Rectangle Is the object empty?.
Returns:
-
Type:
-
Boolean
If Rectangle If the object's width or height is less than or equal to 0, the true value is returned, otherwise false is returned.
setTo(x, y, width, height) → {Rectangle}
take Rectangle Property is set to the specified value.
Parameters:
Name |
Type |
Description |
x |
Number
|
X axis coordinates in the upper left corner of the X rectangle.
|
y |
Number
|
Y axis coordinates in the upper left corner of the X rectangle.
|
width |
Number
|
Width of rectangle.
|
height |
Number
|
Rectangular height.
|
Returns:
-
Type:
-
Rectangle
Returns the rectangular object itself after the property value has been modified.
toString()
current Rectangle The horizontal position of the object, X and vertical position Y, and strings of height width and width height joined in commas.
union(要添加到此, outopt) → {Rectangle}
The rectangular Union, by filling the horizontal and vertical spaces between the two rectangles, combines the two rectangles together to create a new one Rectangle Object.
Note: the Union () method ignores a rectangle whose height or width is 0, such as: VaR, rect2:Rectangle = new, Rectangle (300300,50,0);
Parameters:
Name |
Type |
Attributes |
Default |
Description |
要添加到此 |
Rectangle
|
|
|
Rectangle Object Rectangle Object.
|
out |
Rectangle
|
<optional>
|
null
|
out A rectangular object used to store output results. If it is null, a new one is created. Recommendation: reuse objects as much as possible and reduce object creation costs. Rectangle.TEMP objects are used for object reuse.
|
Returns:
-
Type:
-
Rectangle
A new combination that serves as the union of two rectangles Rectangle Object.