scaleToCover method

void scaleToCover(
  1. Size target
)

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.

This function assumes that both Sizes contain strictly positive dimensions. @param {!goog.math.Size} target The target size.

Implementation

void scaleToCover(Size target)
{
  double s;

  if ( aspectRatio() <= target.aspectRatio() ) {
    s = target.width / width;
  }
  else {
    s = target.height / height;
  }

  scale(s, s);
}