LRectangle Class
A LRectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its width and its height.
The x, y, width, and height properties of the LRectangle class are independent of each other; changing the value of one property has no effect on the others. However, the right and bottom properties are integrally related to those four properties. For example, if you change the value of the right property, the value of the width property changes; if you change the bottom property, the value of the height property changes.
Constructor
LRectangle
-
x
-
y
-
width
-
height
Parameters:
-
x
FloatThe x coordinate of the top-left corner of the rectangle.
-
y
FloatThe y coordinate of the top-left corner of the rectangle.
-
width
FloatThe width of the rectangle, in pixels.
-
height
FloatThe height of the rectangle, in pixels.
Item Index
Methods
clone
()
LRectangle
public
Returns a new LRectangle object with the same values for the x, y, width, and height properties as the original LRectangle object.
Returns:
A new LRectangle object with the same values for the x, y, width, and height properties as the original LRectangle object.
contains
-
x
-
y
Determines whether the specified point is contained within the rectangular region defined by this LRectangle object.
Parameters:
-
x
FloatThe x coordinate (horizontal position) of the point.
-
y
FloatThe y coordinate (vertical position) of the point.
Returns:
A value of true if the LRectangle object contains the specified point; otherwise false.
containsRect
-
rect
Determines whether the LRectangle object specified by the rect parameter is contained within this LRectangle object. A LRectangle object is said to contain another if the second LRectangle object falls entirely within the boundaries of the first.
Parameters:
-
rect
LRectangleThe LRectangle object being checked.
Returns:
A value of true if the LRectangle object that you specify is contained by this LRectangle object; otherwise false.
equals
-
toCompare
Determines whether the LRectangle object specified by the rect parameter is contained within this LRectangle object. A LRectangle object is said to contain another if the second LRectangle object falls entirely within the boundaries of the first.
Parameters:
-
toCompare
LRectangleThe LRectangle object being checked.
Returns:
A value of true if the LRectangle object that you specify is contained by this LRectangle object; otherwise false.
inflate
-
dx
-
dy
Increases the size of the LRectangle object by the specified amounts, in pixels. The center point of the LRectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value.
Parameters:
-
dx
FloatThe value to be added to the left and the right of the LRectangle object.
-
dy
FloatThe value to be added to the top and the bottom of the LRectangle object.
intersection
-
toIntersect
If the LRectangle object specified in the toIntersect parameter intersects with this LRectangle object, returns the area of intersection as a LRectangle object. If the rectangles do not intersect, this method returns an empty LRectangle object with its properties set to 0.
Parameters:
-
toIntersect
LRectangleThe LRectangle object to compare against to see if it intersects with this LRectangle object.
Returns:
A LRectangle object that equals the area of intersection. If the rectangles do not intersect, this method returns an empty LRectangle object; that is, a rectangle with its x, y, width, and height properties set to 0.
intersects
-
toIntersect
Determines whether the object specified in the toIntersect parameter intersects with this LRectangle object. This method checks the x, y, width, and height properties of the specified LRectangle object to see if it intersects with this LRectangle object.
Parameters:
-
toIntersect
LRectangleThe LRectangle object to compare against this LRectangle object.
Returns:
A value of true if the specified object intersects with this LRectangle object; otherwise false.
isEmpty
()
Boolean
public
Determines whether or not this LRectangle object is empty.
Returns:
A value of true if the LRectangle object's width or height is less than or equal to 0; otherwise false.
offset
-
dx
-
dy
Adjusts the location of the LRectangle object, as determined by its top-left corner, by the specified amounts.
Parameters:
-
dx
FloatMoves the x value of the LRectangle object by this amount.
-
dy
FloatMoves the y value of the LRectangle object by this amount.
setEmpty
()
public
Sets all of the LRectangle object's properties to 0. A LRectangle object is empty if its width or height is less than or equal to 0. This method sets the values of the x, y, width, and height properties to 0.
setTo
-
xa
-
ya
-
widtha
-
heighta
Sets the members of LRectangle to the specified values
Parameters:
-
xa
Floatthe values to set the rectangle to.
-
ya
Floatthe values to set the rectangle to.
-
widtha
Floatthe values to set the rectangle to.
-
heighta
Floatthe values to set the rectangle to.
union
-
toUnion
Adds two rectangles together to create a new LRectangle object, by filling in the horizontal and vertical space between the two rectangles.
Parameters:
-
toUnion
LRectangleA LRectangle object to add to this Rectangle object.
Returns:
A new LRectangle object that is the union of the two rectangles.