Size class

Class for representing sizes consisting of a width and height. Undefined width and height support is deprecated and results in compiler warning. @param {number} width Width. @param {number} height Height. @struct @constructor

Implemented types

Constructors

Size([double width = 0.0, double height = 0.0])
Size.parseFromAttribute(String data)
factory

Properties

hashCode int
The hash code for this object.
no setteroverride
height double
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
width double
getter/setter pair

Methods

area() double
@return {number} The area of the size (width * height).
aspectRatio() double
@return {number} The ratio of the size's width to its height.
copy() Size
@return {!goog.math.Size} A new copy of this Size.
fitsInside(Size target) bool
@param {!goog.math.Size} target The target size. @return {bool} True if this Size is the same size or smaller than the target size in both dimensions.
getAxis(Axis axis) double
Get axis. Enables general code to be written without knowing which axis ahead of time.
getLongest() double
@return {number} The longer of the two dimensions in the size.
getShortest() double
@return {number} The shorter of the two dimensions in the size.
isEmpty() bool
@return {bool} True if the size has zero area, false if both dimensions are non-zero numbers.
marshal(MarshalledObject marshalled) → void
Marshal method must operate by mutating empty object passed.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
perimeter() double
@return {number} The perimeter of the size (width + height) * 2.
rotate90() → void
Rotate size around 90 degrees (same effect as 270)
scale(double sx, double sy) → void
Scales this size by the given scale factors. The width and height are scaled by {@code sx} and {@code opt_sy} respectively. If {@code opt_sy} is not given, then {@code sx} is used for both the width and height. @param {number} sx The scale factor to use for the width. @param {number=} opt_sy The scale factor to use for the height. @return {!goog.math.Size} This Size object after scaling.
scaleDimension(Axis axis, double s) → void
Scale so that specified dimension matches specified value.
scaleToCover(Size target) → void
Uniformly scales the size to perfectly cover the dimensions of a given size. If the size is already larger than the target, it will be scaled down to the minimum size at which it still covers the entire target. The original aspect ratio will be preserved.
scaleToFit(Size target) → void
Uniformly scales the size to fit inside the dimensions of a given size. The original aspect ratio will be preserved.
toAttributeString() String
Size to attribute string
toCoordinate() Coordinate
toRect() Rect
toString() String
Returns a nice string representing size. @return {string} In the form (50 x 73). @override
override

Operators

operator ==(Object other) bool
Compares sizes for equality.
override

Static Properties

naught Size
Empty size
final

Static Methods

unmarshal(MarshalledObject marshalled) Size
Encoded object parameter is encoded depending on format.