Class goog.math.Box
code »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. This class assumes 'screen coordinates': larger Y coordinates are further from the top of the screen.
Constructor
Instance Methods
code »ceil ( ) ⇒ !goog.math.Box
Rounds the fields to the next larger integer values.
!goog.math.Box
Returns |
---|
|
code »clone ( ) ⇒ !goog.math.Box
Creates a copy of the box with the same dimensions.
!goog.math.Box
Returns |
---|
|
Returns whether the box contains a coordinate or another box.
Parameters |
---|
|
Returns |
|
code »expand ( top, opt_right, opt_bottom, opt_left ) ⇒ !goog.math.Box
Expands box with the given margins.
!goog.math.Box
Parameters |
---|
|
Returns |
|
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).
Parameters |
---|
|
code »floor ( ) ⇒ !goog.math.Box
Rounds the fields to the next smaller integer values.
!goog.math.Box
Returns |
---|
|
code »round ( ) ⇒ !goog.math.Box
Rounds the fields to nearest integer values.
!goog.math.Box
Returns |
---|
|
code »scale ( sx, opt_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.
!goog.math.Box
sx
and opt_sy
respectively.
If opt_sy
is not given, then sx
is used for both x and y.code »translate ( tx, opt_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.
!goog.math.Box
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.Parameters |
---|
|
Returns |
|
Instance Properties
Static Functions
code »goog.math.Box.boundingBox ( var_args ) ⇒ !goog.math.Box
Creates a Box by bounding a collection of goog.math.Coordinate objects
!goog.math.Box
Parameters |
---|
|
Returns |
|
code »goog.math.Box.contains ( box, other ) ⇒ boolean
Returns whether a box contains a coordinate or another box.
boolean
Parameters |
---|
|
Returns |
|
code »goog.math.Box.distance ( box, coord ) ⇒ number
Returns the distance between a coordinate and the nearest corner/side of a
box. Returns zero if the coordinate is inside the box.
number
Parameters |
---|
|
Returns |
coord and the nearest
corner/side of box , or zero if coord is inside
box . |
code »goog.math.Box.equals ( a, b ) ⇒ boolean
Compares boxes for equality.
boolean
Parameters |
---|
|
Returns |
|
code »goog.math.Box.intersects ( a, b ) ⇒ boolean
Returns whether two boxes intersect.
boolean
Parameters |
---|
|
Returns |
|
code »goog.math.Box.intersectsWithPadding ( a, b, padding ) ⇒ boolean
Returns whether two boxes would intersect with additional padding.
boolean
Parameters |
---|
|
Returns |
|
code »goog.math.Box.relativePositionX ( box, coord ) ⇒ number
Returns the relative x position of a coordinate compared to a box. Returns
zero if the coordinate is inside the box.
number
Parameters |
---|
|
Returns |
coord relative to the nearest
side of box , or zero if coord is inside box . |
code »goog.math.Box.relativePositionY ( box, coord ) ⇒ number
Returns the relative y position of a coordinate compared to a box. Returns
zero if the coordinate is inside the box.
number
Parameters |
---|
|
Returns |
coord relative to the nearest
side of box , or zero if coord is inside box . |