The goog.math.Size Class

goog.math.Size(width, height)

Class for representing sizes consisting of a width and height. Undefined width and height support is deprecated and results in compiler warning.

width {number}
Width.
height {number}
Height.

.area()

returns {number}
The area of the size (width * height).

.aspectRatio()

returns {number}
The ratio of the size's width to its height.

.ceil()

Clamps the width and height parameters upward to integer values.

returns {!goog.math.Size}
This size with ceil'd components.

.clone()

returns {!goog.math.Size}
A new copy of the Size.

.equals(a, b)

Compares sizes for equality.

a {goog.math.Size}
A Size.
b {goog.math.Size}
A Size.
returns {boolean}
True iff the sizes have equal widths and equal heights, or if both are null.

.fitsInside(target)

target {!goog.math.Size}
The target size.
returns {boolean}
True if this Size is the same size or smaller than the target size in both dimensions.

.floor()

Clamps the width and height parameters downward to integer values.

returns {!goog.math.Size}
This size with floored components.

.getLongest()

returns {number}
The longer of the two dimensions in the size.

.getShortest()

returns {number}
The shorter of the two dimensions in the size.

.height {number}

Height

.isEmpty()

returns {boolean}
True if the size has zero area, false if both dimensions are non-zero numbers.

.perimeter()

returns {number}
The perimeter of the size (width + height) * 2.

.round()

Rounds the width and height parameters to integer values.

returns {!goog.math.Size}
This size with rounded components.

.scale(s)

Scales the size uniformly by a factor.

s {number}
The scale factor.
returns {!goog.math.Size}
This Size object after scaling.

.scaleToFit(target)

Uniformly scales the size to fit inside the dimensions of a given size. The original aspect ratio will be preserved. This function assumes that both Sizes contain strictly positive dimensions.

target {!goog.math.Size}
The target size.
returns {!goog.math.Size}
This Size object, after optional scaling.

.toString()

Returns a nice string representing size.

returns {string}
In the form (50 x 73).

.width {number}

Width