scaleToFit method
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. @param {!goog.math.Size} target The target size.
Implementation
void scaleToFit(Size target)
{
double s;
if ( aspectRatio() > target.aspectRatio() ) {
s = target.width / width;
}
else {
s = target.height / height;
}
scale(s, s);
}