API Docs for: 最后更新日期:2014年8月25日
Google搜索   
Show:

LRectangle Class

Defined in: geom/LRectangle.js:1

Available since 1.4.1

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
)
public

Defined in geom/LRectangle.js:1

Available since 1.4.1

Parameters:

  • x Float

    The x coordinate of the top-left corner of the rectangle.

  • y Float

    The y coordinate of the top-left corner of the rectangle.

  • width Float

    The width of the rectangle, in pixels.

  • height Float

    The height of the rectangle, in pixels.

Methods

clone

() LRectangle public

Defined in geom/LRectangle.js:30

Available since 1.4.1

Returns a new LRectangle object with the same values for the x, y, width, and height properties as the original LRectangle object.

Returns:

LRectangle:

A new LRectangle object with the same values for the x, y, width, and height properties as the original LRectangle object.

contains

(
  • x
  • y
)
Boolean public

Defined in geom/LRectangle.js:41

Available since 1.4.1

Determines whether the specified point is contained within the rectangular region defined by this LRectangle object.

Parameters:

  • x Float

    The x coordinate (horizontal position) of the point.

  • y Float

    The y coordinate (vertical position) of the point.

Returns:

Boolean:

A value of true if the LRectangle object contains the specified point; otherwise false.

containsRect

(
  • rect
)
Boolean public

Defined in geom/LRectangle.js:54

Available since 1.4.1

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 LRectangle

    The LRectangle object being checked.

Returns:

Boolean:

A value of true if the LRectangle object that you specify is contained by this LRectangle object; otherwise false.

equals

(
  • toCompare
)
Boolean public

Defined in geom/LRectangle.js:66

Available since 1.4.1

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 LRectangle

    The LRectangle object being checked.

Returns:

Boolean:

A value of true if the LRectangle object that you specify is contained by this LRectangle object; otherwise false.

inflate

(
  • dx
  • dy
)
public

Defined in geom/LRectangle.js:78

Available since 1.4.1

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 Float

    The value to be added to the left and the right of the LRectangle object.

  • dy Float

    The value to be added to the top and the bottom of the LRectangle object.

intersection

(
  • toIntersect
)
Boolean public

Defined in geom/LRectangle.js:92

Available since 1.4.1

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 LRectangle

    The LRectangle object to compare against to see if it intersects with this LRectangle object.

Returns:

Boolean:

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
)
Boolean public

Defined in geom/LRectangle.js:112

Available since 1.4.1

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 LRectangle

    The LRectangle object to compare against this LRectangle object.

Returns:

Boolean:

A value of true if the specified object intersects with this LRectangle object; otherwise false.

isEmpty

() Boolean public

Defined in geom/LRectangle.js:128

Available since 1.4.1

Determines whether or not this LRectangle object is empty.

Returns:

Boolean:

A value of true if the LRectangle object's width or height is less than or equal to 0; otherwise false.

offset

(
  • dx
  • dy
)
public

Defined in geom/LRectangle.js:139

Available since 1.4.1

Adjusts the location of the LRectangle object, as determined by its top-left corner, by the specified amounts.

Parameters:

  • dx Float

    Moves the x value of the LRectangle object by this amount.

  • dy Float

    Moves the y value of the LRectangle object by this amount.

setEmpty

() public

Defined in geom/LRectangle.js:153

Available since 1.4.1

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
)
public

Defined in geom/LRectangle.js:167

Available since 1.4.1

Sets the members of LRectangle to the specified values

Parameters:

  • xa Float

    the values to set the rectangle to.

  • ya Float

    the values to set the rectangle to.

  • widtha Float

    the values to set the rectangle to.

  • heighta Float

    the values to set the rectangle to.

union

(
  • toUnion
)
LRectangle public

Defined in geom/LRectangle.js:189

Available since 1.4.1

Adds two rectangles together to create a new LRectangle object, by filling in the horizontal and vertical space between the two rectangles.

Parameters:

  • toUnion LRectangle

    A LRectangle object to add to this Rectangle object.

Returns:

LRectangle:

A new LRectangle object that is the union of the two rectangles.