# 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:Public Protected Private

## Instance Methods

code »area ( ) ⇒ `number`

Returns
The area of the size (width * height).

code »aspectRatio ( ) ⇒ `number`

Returns
The ratio of the size's width to its height.

code »ceil ( ) ⇒ `!goog.math.Size`

Clamps the width and height parameters upward to integer values.

Returns
This size with ceil'd components.

code »clone ( ) ⇒ `!goog.math.Size`

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.

code »floor ( ) ⇒ `!goog.math.Size`

Clamps the width and height parameters downward to integer values.

Returns
This size with floored components.

code »getLongest ( ) ⇒ `number`

Returns
The longer of the two dimensions in the size.

code »getShortest ( ) ⇒ `number`

Returns
The shorter of the two dimensions in the size.

code »isEmpty ( ) ⇒ `boolean`

Returns
True if the size has zero area, false if both dimensions are non-zero numbers.

code »perimeter ( ) ⇒ `number`

Returns
The perimeter of the size (width + height) * 2.

code »round ( ) ⇒ `!goog.math.Size`

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.

code »scaleToFit ( target ) ⇒ `!goog.math.Size`

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.

code »toString ( ) ⇒ `string`

Returns a nice string representing size.

Returns
In the form (50 x 73).

## Instance Properties

code »height : `number`

Height

code »width : `number`

Width

## Static Functions

code »goog.math.Size.equals ( a, b ) ⇒ `boolean`

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.