Class Index | File Index

Classes


Class R.math.Rectangle2D


Extends R.math.PooledMathObject.
A 2D rectangle class with helpful manipulation methods.
Defined in: rectangle2d.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
R.math.Rectangle2D(x, y, width, height)
Create a rectangle object specifying the X and Y position and the width and height.
Method Summary
Method Attributes Method Name and Description
 
add(point)
A mutator method that adds the point to the top left of this rectangle.
 
Returns true if this rectangle contains the specified point.
 
Determine if this rectangle contains the specified rectangle.
 
convolve(point)
A mutator method that multiplies the top left of this rectangle with the point specified.
 
A mutator method that divides the top left of this rectangle with the point specified.
 
Destroy the rectangle instance
 
equals(rect)
Returns true if this rectangle is equal to the specified rectangle.
 
get()
Get an object with the elements containing left, top, width, height, right and bottom as the elements x, y, w, h, r, and b.
 
Gets a R.math.Point2D representing the bottom-right corner of this rectangle.
 
Returns a R.math.Point2D that contains the center point of this rectangle.
 
Return the classname of the this object
 
Gets a {@link R.math.Point2D) representing the width and height of this rectangle.
 
Returns the half length of the height dimension of this rectangle
 
Returns the half length of the width dimension of this rectangle
 
Gets a R.math.Point2D representing the top-left corner of this rectangle.
 
grow(pixelsX, pixelsY)
Grow the size of the rectangle by the amounts given.
 
Determine if this rectangle is contained within the specified rectangle.
 
Determine if this rectangle intersects another rectangle.
 
join(rect)
Mutator method which will join this rectangle with another rectangle.
 
Returns the positive length of this rectangle, along the X axis.
 
Returns the positive length of this rectangle, along the Y axis.
 
offset(offsetPtOrX, offsetY)
A mutator method that offsets this rectangle by the given amount in the X and Y axis.
 
Release the rectangle back into the pool for reuse
 
set(x, y, width, height)
Set the values of this rectangle.
 
setDims(ptOrX, y)
Set the width and height of this rectangle using the point, or coordinates specified.
 
setHeight(height)
Set the height of the rectangle
 
setTopLeft(ptOrX, y)
Set the top left of this rectangle to the point, or coordinates specified.
 
setWidth(width)
Set the width of the rectangle.
 
shrink(pixelsX, pixelsY)
Shrink the size of the rectangle by the amounts given.
 
sub(point)
A mutator method that subtracts the point from the top left of this rectangle.
 
Returns a printable version of this object.
Methods borrowed from class R.engine.PooledObject:
clearObjectDataModel, getId, getName, getObjectDataModel, getProperties, isDestroyed, setName, setObjectDataModel, toXML
Class Detail
R.math.Rectangle2D(x, y, width, height)
Create a rectangle object specifying the X and Y position and the width and height.
Parameters:
x
{R.math.Rectangle2D|Number} A rectangle to clone, or the top-left X coordinate
y
{Number} The top-left Y coordinate
width
{Number} the width of the rectangle
height
{Number} The height of the rectangle
Method Detail
add(point)
A mutator method that adds the point to the top left of this rectangle.
Parameters:
point
{R.math.Point2D}

{Boolean} containsPoint(point)
Returns true if this rectangle contains the specified point.
Parameters:
point
{R.math.Point} The point to test
Returns:
{Boolean} true if the point is within this rectangle

{Boolean} containsRect(rect)
Determine if this rectangle contains the specified rectangle.
Parameters:
rect
A R.math.Rectangle2D to compare against
Returns:
{Boolean} true if the rectangle is fully contained within this rectangle.

convolve(point)
A mutator method that multiplies the top left of this rectangle with the point specified.
Parameters:
point
{R.math.Point2D}

convolveInverse(point)
A mutator method that divides the top left of this rectangle with the point specified.
Parameters:
point
{R.math.Point2D}

destroy()
Destroy the rectangle instance

{Boolean} equals(rect)
Returns true if this rectangle is equal to the specified rectangle.
Parameters:
rect
{R.math.Rectangle2D} The rectangle to compare to
Returns:
{Boolean} true if the two rectangles are equal

{Object} get()
Get an object with the elements containing left, top, width, height, right and bottom as the elements x, y, w, h, r, and b.
Returns:
{Object} An object with the specified elements

{R.math.Point2D} getBottomRight()
Gets a R.math.Point2D representing the bottom-right corner of this rectangle.
Returns:
{R.math.Point2D}

{R.math.Point2D} getCenter()
Returns a R.math.Point2D that contains the center point of this rectangle.
Returns:
{R.math.Point2D} The center point of the rectangle

{String} getClassName()
Return the classname of the this object
Returns:
{String} "R.math.Rectangle2D"

{R.math.Point2D} getDims()
Gets a {@link R.math.Point2D) representing the width and height of this rectangle.
Returns:
{R.math.Point2D}

{Number} getHalfHeight()
Returns the half length of the height dimension of this rectangle
Returns:
{Number} The half-height

{Number} getHalfWidth()
Returns the half length of the width dimension of this rectangle
Returns:
{Number} The half-width

{R.math.Point2D} getTopLeft()
Gets a R.math.Point2D representing the top-left corner of this rectangle.
Returns:
{R.math.Point2D}

grow(pixelsX, pixelsY)
Grow the size of the rectangle by the amounts given.
Parameters:
pixelsX
{Number} The pixels to grow the rectangle along the X axis, or both.
pixelsY Optional
{Number} If defined, the pixels to grow the rectangle along the Y axis.

{Boolean} isContained(rect)
Determine if this rectangle is contained within the specified rectangle.
Parameters:
rect
A R.math.Rectangle2D to compare against
Returns:
{Boolean} true if the this rectangle is fully contained in the specified rectangle.

{Boolean} isIntersecting(rect)
Determine if this rectangle intersects another rectangle.
Parameters:
rect
A R.math.Rectangle2D to compare against
Returns:
{Boolean} true if the two rectangles intersect.

{R.math.Rectangle2D} join(rect)
Mutator method which will join this rectangle with another rectangle. Joining two rectangles will create a rectangle that would enclose both rectangles. It is best to see if two rectangles are overlapping before joining them, since joining two disjoint rectangles would enclose areas not contained in either.
Parameters:
rect
{R.math.Rectangle2D} The rectangle to join with
Returns:
{R.math.Rectangle2D} This rectangle

{Number} len_x()
Returns the positive length of this rectangle, along the X axis.
Returns:
{Number}

{Number} len_y()
Returns the positive length of this rectangle, along the Y axis.
Returns:
{Number}

{R.math.Rectangle2D} offset(offsetPtOrX, offsetY)
A mutator method that offsets this rectangle by the given amount in the X and Y axis. The first parameter can be either a point, or the value for the X axis. If the X axis is specified, the second parameter should be the amount to offset in the Y axis.
Parameters:
offsetPtOrX
{R.math.Point2D|int} Either a R.math.Point which contains the offset in X and Y, or an integer representing the offset in the X axis.
offsetY
{int} If offsetPtOrX is an integer value for the offset in the X axis, this should be the offset along the Y axis.
Returns:
{R.math.Rectangle2D} This rectangle

release()
Release the rectangle back into the pool for reuse

set(x, y, width, height)
Set the values of this rectangle.
Parameters:
x
{Array|Number|R.math.Rectangle2D} An optional value to initialize the X coordinate of the rectangle, or a rectangle to clone
y
{Number} An optional value to initialize the Y coordinate of the rectangle
width
{Number} An optional value to initialize the width of the rectangle
height
{Number} An optional value to initialize the height of the rectangle

setDims(ptOrX, y)
Set the width and height of this rectangle using the point, or coordinates specified.
Parameters:
ptOrX
{Point2D|Number} A R.math.Point2D, or the X coordinate
y Optional
{Number} If the top left isn't a point, this is the Y coordinate

setHeight(height)
Set the height of the rectangle
Parameters:
height
{Number} The new height of the rectangle

setTopLeft(ptOrX, y)
Set the top left of this rectangle to the point, or coordinates specified.
Parameters:
ptOrX
{R.math.Point2D|Number} The top left R.math.Point2D, or the X coordinate
y
{Number} If the top left wasn't specified as the first argument, this is the Y coordinate

setWidth(width)
Set the width of the rectangle.
Parameters:
width
{Number} The new width of the rectangle

shrink(pixelsX, pixelsY)
Shrink the size of the rectangle by the amounts given.
Parameters:
pixelsX
{Number} The pixels to shrink the rectangle along the X axis, or both.
pixelsY Optional
{Number} If defined, the pixels to shrink the rectangle along the Y axis.

sub(point)
A mutator method that subtracts the point from the top left of this rectangle.
Parameters:
point
{R.math.Point2D}

{String} toString()
Returns a printable version of this object.
Returns:
{String} Formatted like "x,y [w,h]"

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Mar 18 2013 16:09:19 GMT-0400 (EDT)