goog.math.Box
Provided By |
---|
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.
new Box( top, right, bottom, left )
Parameters |
|
---|
Instance Methods
this.ceil() → goog.math.Box
goog.math.Box
Rounds the fields to the next larger integer values.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.clone() → goog.math.Box
goog.math.Box
Creates a copy of the box with the same dimensions.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.contains( other ) → boolean
boolean
Returns whether the box contains a coordinate or another box.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.expand( top, opt_right, opt_bottom, opt_left ) → goog.math.Box
goog.math.Box
Expands box with the given margins.
Parameters |
| ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.expandToInclude( box ) → void
void
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 |
|
---|
this.expandToIncludeCoordinate( coord ) → void
void
Expand this box to include the coordinate.
Parameters |
|
---|
this.floor() → goog.math.Box
goog.math.Box
Rounds the fields to the next smaller integer values.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getHeight() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getWidth() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.round() → goog.math.Box
goog.math.Box
Rounds the fields to nearest integer values.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.scale( sx, opt_sy ) → goog.math.Box
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.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.toString() → string
string
Returns a nice string representing the box.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.translate( tx, opt_ty ) → goog.math.Box
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.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Instance Properties
this.bottom → number
number
Bottom
this.left → number
number
Left
this.right → number
number
Right
this.top → number
number
Top
Static Functions
Box.boundingBox( ...var_args ) → goog.math.Box
goog.math.Box
Creates a Box by bounding a collection of goog.math.Coordinate objects
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
Box.contains( box, other ) → boolean
boolean
Returns whether a box contains a coordinate or another box.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Box.distance( box, coord ) → number
number
Returns the distance between a coordinate and the nearest corner/side of a box. Returns zero if the coordinate is inside the box.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Box.equals( a, b ) → boolean
boolean
Compares boxes for equality.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Box.intersects( a, b ) → boolean
boolean
Returns whether two boxes intersect.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Box.intersectsWithPadding( a, b, padding ) → boolean
boolean
Returns whether two boxes would intersect with additional padding.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
Box.relativePositionX( box, coord ) → number
number
Returns the relative x position of a coordinate compared to a box. Returns zero if the coordinate is inside the box.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Box.relativePositionY( box, coord ) → number
number
Returns the relative y position of a coordinate compared to a box. Returns zero if the coordinate is inside the box.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|