math.Rect Extends
Class for representing rectangular regions.

Inheritance

Constructor

goog.math.Rect(xywh)

Parameters

x : number
Left.
y : number
Top.
w : number
Width.
h : number
Height.

Instance Methods

Public Protected Private
Defined in goog.math.Rect
boundingRect(rect)
Expand this rectangle to also include the area of the given rectangle.
Arguments:
rect : goog.math.Rect
The other rectangle.
code »
ceil() !goog.math.Rect
Rounds the fields to the next larger integer values.
Returns: !goog.math.Rect  This rectangle with ceil'd fields.
code »
clone() !goog.math.Rect
No description.
Returns: !goog.math.Rect  A new copy of this Rectangle.
code »
contains(another) boolean
Tests whether this rectangle entirely contains another rectangle or coordinate.
Arguments:
another : goog.math.Rect | goog.math.Coordinate
The rectangle or coordinate to test for containment.
Returns: boolean  Whether this rectangle contains given rectangle or coordinate.
code »
difference(rect) !Array.<!goog.math.Rect>
Computes the difference regions between this rectangle and rect. The return value is an array of 0 to 4 rectangles defining the remaining regions of this rectangle after the other has been subtracted.
Arguments:
rect : goog.math.Rect
A Rectangle.
Returns: !Array.<!goog.math.Rect>  An array with 0 to 4 rectangles which together define the difference area of rectangle a minus rectangle b.
code »
distance(point) number
No description.
Arguments:
point : !goog.math.Coordinate
A coordinate.
Returns: number  The distance between the point and the closest point inside the rectangle. Returns 0 if the point is inside the rectangle.
code »
floor() !goog.math.Rect
Rounds the fields to the next smaller integer values.
Returns: !goog.math.Rect  This rectangle with floored fields.
code »
getBottomRight() !goog.math.Coordinate
No description.
Returns: !goog.math.Coordinate  A new coordinate for the bottom-right corner of the rectangle.
code »
getCenter() !goog.math.Coordinate
No description.
Returns: !goog.math.Coordinate  A new coordinate for the center of the rectangle.
code »
getSize() !goog.math.Size
No description.
Returns: !goog.math.Size  The size of this rectangle.
code »
getTopLeft() !goog.math.Coordinate
No description.
Returns: !goog.math.Coordinate  A new coordinate for the top-left corner of the rectangle.
code »
intersection(rect) boolean
Computes the intersection of this rectangle and the rectangle parameter. If there is no intersection, returns false and leaves this rectangle as is.
Arguments:
rect : goog.math.Rect
A Rectangle.
Returns: boolean  True iff this rectangle intersects with the parameter.
code »
intersects(rect) boolean
Returns whether a rectangle intersects this rectangle.
Arguments:
rect : goog.math.Rect
A rectangle.
Returns: boolean  Whether rect intersects this rectangle.
code »
round() !goog.math.Rect
Rounds the fields to nearest integer values.
Returns: !goog.math.Rect  This rectangle with rounded fields.
code »
scale(sxopt_sy) !goog.math.Rect
Scales this rectangle by the given scale factors. The left and width values are scaled by sx and the top and height values are scaled by opt_sy. If opt_sy is not given, then all fields are scaled by sx.
Arguments:
sx : number
The scale factor to use for the x dimension.
opt_sy : number=
The scale factor to use for the y dimension.
Returns: !goog.math.Rect  This rectangle after scaling.
code »
squaredDistance(point) number
No description.
Arguments:
point : !goog.math.Coordinate
A coordinate.
Returns: number  The squared distance between the point and the closest point inside the rectangle. Returns 0 if the point is inside the rectangle.
code »
toBox() !goog.math.Box
Returns a new Box object with the same position and dimensions as this rectangle.
Returns: !goog.math.Box  A new Box representation of this Rectangle.
code »
toString() string
Returns a nice string representing size and dimensions of rectangle.
Returns: string  In the form (50, 73 - 75w x 25h).
code »
translate(txopt_ty) !goog.math.Rect
Translates this rectangle by the given offsets. If a goog.math.Coordinate is given, then the left and top values are translated by the coordinate's x and y values. Otherwise, top and left are translated by tx and opt_ty respectively.
Arguments:
tx : number | goog.math.Coordinate
The value to translate left by or the the coordinate to translate this rect by.
opt_ty : number=
The value to translate top by.
Returns: !goog.math.Rect  This rectangle after translating.
code »

Instance Properties

Defined in goog.math.Rect
height :
No description.
Code »
left :
No description.
Code »
top :
No description.
Code »
width :
No description.
Code »

Static Methods

goog.math.Rect.boundingRect(ab) goog.math.Rect
Returns a new rectangle which completely contains both input rectangles.
Arguments:
a : goog.math.Rect
A rectangle.
b : goog.math.Rect
A rectangle.
Returns: goog.math.Rect  A new bounding rect, or null if either rect is null.
code »
goog.math.Rect.createFromBox(box) !goog.math.Rect
Creates a new Rect object with the same position and dimensions as a given Box. Note that this is only the inverse of toBox if left/top are defined.
Arguments:
box : goog.math.Box
A box.
Returns: !goog.math.Rect  A new Rect initialized with the box's position and size.
code »
goog.math.Rect.difference(ab) !Array.<!goog.math.Rect>
Computes the difference regions between two rectangles. The return value is an array of 0 to 4 rectangles defining the remaining regions of the first rectangle after the second has been subtracted.
Arguments:
a : goog.math.Rect
A Rectangle.
b : goog.math.Rect
A Rectangle.
Returns: !Array.<!goog.math.Rect>  An array with 0 to 4 rectangles which together define the difference area of rectangle a minus rectangle b.
code »
goog.math.Rect.equals(ab) boolean
Compares rectangles for equality.
Arguments:
a : goog.math.Rect
A Rectangle.
b : goog.math.Rect
A Rectangle.
Returns: boolean  True iff the rectangles have the same left, top, width, and height, or if both are null.
code »
goog.math.Rect.intersection(ab) goog.math.Rect
Returns the intersection of two rectangles. Two rectangles intersect if they touch at all, for example, two zero width and height rectangles would intersect if they had the same top and left.
Arguments:
a : goog.math.Rect
A Rectangle.
b : goog.math.Rect
A Rectangle.
Returns: goog.math.Rect  A new intersection rect (even if width and height are 0), or null if there is no intersection.
code »
goog.math.Rect.intersects(ab) boolean
Returns whether two rectangles intersect. Two rectangles intersect if they touch at all, for example, two zero width and height rectangles would intersect if they had the same top and left.
Arguments:
a : goog.math.Rect
A Rectangle.
b : goog.math.Rect
A Rectangle.
Returns: boolean  Whether a and b intersect.
code »

Package math

Package Reference