Class goog.math.Size

code »

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

Constructor

goog.math.Size ( width, height )
Parameters
width: number
Width.
height: number
Height.
Show:

Instance Methods

Returns
The area of the size (width * height).
Returns
The ratio of the size's width to its height.

Clamps the width and height parameters upward to integer values.

Returns
This size with ceil'd components.
Returns
A new copy of the Size.
code »fitsInside ( target )boolean
Parameters
target: !goog.math.Size
The target size.
Returns
True if this Size is the same size or smaller than the target size in both dimensions.

Clamps the width and height parameters downward to integer values.

Returns
This size with floored components.
Returns
The longer of the two dimensions in the size.
Returns
The shorter of the two dimensions in the size.
Returns
True if the size has zero area, false if both dimensions are non-zero numbers.
Returns
The perimeter of the size (width + height) * 2.

Rounds the width and height parameters to integer values.

Returns
This size with rounded components.
code »scale ( sx, opt_sy )!goog.math.Size

Scales this size by the given scale factors. The width and height are scaled by sx and opt_sy respectively. If opt_sy is not given, then sx is used for both the width and height.

Parameters
sx: number
The scale factor to use for the width.
opt_sy: number=
The scale factor to use for the height.
Returns
This Size object after scaling.

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.

Parameters
target: !goog.math.Size
The target size.
Returns
This Size object, after optional scaling.

Returns a nice string representing size.

Returns
In the form (50 x 73).

Instance Properties

Static Functions

Compares sizes for equality.

Parameters
a: goog.math.Size
A Size.
b: goog.math.Size
A Size.
Returns
True iff the sizes have equal widths and equal heights, or if both are null.