rect.maxRectScaleToFit(limitRectangle [, origin])

Returns an object where sx and sy give the maximum scaling that can be applied to the rectangle so that it would still fit into limitRectangle.

If origin is specified, the rectangle is scaled around it; otherwise, it is scaled around its center.