math.Box Extends
Class for representing a box. A box is specified as a top, right, bottom, and left. A box is useful for representing margins and padding.

Inheritance

Constructor

goog.math.Box(toprightbottomleft)

Parameters

top : number
Top.
right : number
Right.
bottom : number
Bottom.
left : number
Left.

Instance Methods

Public Protected Private
Defined in goog.math.Box
ceil() !goog.math.Box
Rounds the fields to the next larger integer values.
Returns: !goog.math.Box  This box with ceil'd fields.
code »
clone() !goog.math.Box
Creates a copy of the box with the same dimensions.
Returns: !goog.math.Box  A clone of this Box.
code »
contains(other) boolean
Returns whether the box contains a coordinate or another box.
Arguments:
other : goog.math.Coordinate | goog.math.Box
A Coordinate or a Box.
Returns: boolean  Whether the box contains the coordinate or other box.
code »
expand(topopt_rightopt_bottomopt_left) !goog.math.Box
Expands box with the given margins.
Arguments:
top : number | goog.math.Box
Top margin or box with all margins.
opt_right : number=
Right margin.
opt_bottom : number=
Bottom margin.
opt_left : number=
Left margin.
Returns: !goog.math.Box  A reference to this Box.
code »
expandToInclude(box)
Expand this box to include another box. NOTE(user): This is used in code that needs to be very fast, please don't add functionality to this function at the expense of speed (variable arguments, accepting multiple argument types, etc).
Arguments:
box : goog.math.Box
The box to include in this one.
code »
floor() !goog.math.Box
Rounds the fields to the next smaller integer values.
Returns: !goog.math.Box  This box with floored fields.
code »
round() !goog.math.Box
Rounds the fields to nearest integer values.
Returns: !goog.math.Box  This box with rounded fields.
code »
scale(sxopt_sy) !goog.math.Box
Scales this coordinate by the given scale factors. The x and y dimension values are scaled by sx and opt_sy respectively. If opt_sy is not given, then sx is used for both x and y.
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.Box  This box after scaling.
code »
toString() string
Returns a nice string representing the box.
Returns: string  In the form (50t, 73r, 24b, 13l).
code »
translate(txopt_ty) !goog.math.Box
Translates this box by the given offsets. If a goog.math.Coordinate is given, then the left and right values are translated by the coordinate's x value and the top and bottom values are translated by the coordinate's y value. Otherwise, tx and opt_ty are used to translate the x and y dimension values.
Arguments:
tx : number | goog.math.Coordinate
The value to translate the x dimension values by or the the coordinate to translate this box by.
opt_ty : number=
The value to translate y dimension values by.
Returns: !goog.math.Box  This box after translating.
code »

Instance Properties

Defined in goog.math.Box
bottom :
Bottom
Code »
left :
Left
Code »
right :
Right
Code »
top :
Top
Code »

Static Methods

goog.math.Box.boundingBox(var_args) !goog.math.Box
Creates a Box by bounding a collection of goog.math.Coordinate objects
Arguments:
var_args : ...goog.math.Coordinate
Coordinates to be included inside the box.
Returns: !goog.math.Box  A Box containing all the specified Coordinates.
code »
goog.math.Box.contains(boxother) boolean
Returns whether a box contains a coordinate or another box.
Arguments:
box : goog.math.Box
A Box.
other : goog.math.Coordinate | goog.math.Box
A Coordinate or a Box.
Returns: boolean  Whether the box contains the coordinate or other box.
code »
goog.math.Box.distance(boxcoord) number
Returns the distance between a coordinate and the nearest corner/side of a box. Returns zero if the coordinate is inside the box.
Arguments:
box : goog.math.Box
A Box.
coord : goog.math.Coordinate
A Coordinate.
Returns: number  The distance between coord and the nearest corner/side of box, or zero if coord is inside box.
code »
goog.math.Box.equals(ab) boolean
Compares boxes for equality.
Arguments:
a : goog.math.Box
A Box.
b : goog.math.Box
A Box.
Returns: boolean  True iff the boxes are equal, or if both are null.
code »
goog.math.Box.intersects(ab) boolean
Returns whether two boxes intersect.
Arguments:
a : goog.math.Box
A Box.
b : goog.math.Box
A second Box.
Returns: boolean  Whether the boxes intersect.
code »
goog.math.Box.intersectsWithPadding(abpadding) boolean
Returns whether two boxes would intersect with additional padding.
Arguments:
a : goog.math.Box
A Box.
b : goog.math.Box
A second Box.
padding : number
The additional padding.
Returns: boolean  Whether the boxes intersect.
code »
goog.math.Box.relativePositionX(boxcoord) number
Returns the relative x position of a coordinate compared to a box. Returns zero if the coordinate is inside the box.
Arguments:
box : goog.math.Box
A Box.
coord : goog.math.Coordinate
A Coordinate.
Returns: number  The x position of coord relative to the nearest side of box, or zero if coord is inside box.
code »
goog.math.Box.relativePositionY(boxcoord) number
Returns the relative y position of a coordinate compared to a box. Returns zero if the coordinate is inside the box.
Arguments:
box : goog.math.Box
A Box.
coord : goog.math.Coordinate
A Coordinate.
Returns: number  The y position of coord relative to the nearest side of box, or zero if coord is inside box.
code »

Package math

Package Reference