     /**
      * Multiplies each coordinate in a rectangle by a scalar value.
      *
-     * @param rect    The rectangle-like object to scale.
-     * @param factor  The number to multiply by.
-     * @param out     An optional instance to store the result in.  If not
-     *                provided, a new Rectangle is created.
-     *
-     * @return  The object containing the multiplied rectangle.
+     * @param rect
+     * The rectangle-like object to scale.
+     *
+     * @param factor
+     * The factor to scale by.
+     *
+     * @param outRect
+     * An optional instance to store the result in.  If not provided, a new
+     * Rectangle is created.
+     *
+     * @return
+     * The object containing the scaled rectangle.
      */
     public static function multiply(
-        rect:*, factor:Number, out:* = null):*
-    {
-        if (!out) out = new Rectangle();
-        out.x = rect.x * factor;
-        out.y = rect.y * factor;
-        out.width = rect.width * factor;
-        out.height = rect.height * factor;
-        return out;
+        rect:*, factor:Number, outRect:* = null):*
+    {
+        if (!outRect) outRect = new Rectangle();
+        outRect.x = rect.x * factor;
+        outRect.y = rect.y * factor;
+        outRect.width = rect.width * factor;
+        outRect.height = rect.height * factor;
+        return outRect;
     }
 
 

     * Scales a rectangle to have a specified area, maintaining its aspect
     * ratio.
     *
     * @param rect  The rectangle to scale.
     * @param area  The desired area.
     * @param out   An optional instance to store the result in.  If not
     *              provided, a new Rectangle is created.
     *
     * @return  The object containing the rectangle with the desired area.
     */
    public static function scaleToArea(
        rect:*, area:Number, out:* = null):*
    {
        if (!out) out = new Rectangle();
        var areaRatio:Number = Math.sqrt(area / (rect.width * rect.height));
        out.x = rect.x;
        out.y = rect.y;
        out.width = rect.width * areaRatio;
        out.height = rect.height * areaRatio;
        return out;
    }
}
}

     * Scales a source rectangle to fit or fill a target rectangle, maintaining
     * the source rectangle's aspect ratio.
     *
     * @param sourceRect
     * The source rectangle.
     *
     * @param targetRect
     * The rectangle to fit <code>sourceRect</code> into.
     *
     * @param mode
     * Fit mode. <code>FitMode.INSIDE</code> returns a rectangle that
     * fits entirely within the target rectangle, <code>FitMode.OUTSIDE</code>
     * returns a rectangle that covers the entirety of the target rectangle.
     *
     * @param xAlign
     * X alignment. A number from 0 to 1. 0 aligns left edges, 1 aligns right
     * edges, and 0.5 centres horizontally. Other values interpolate between
     * these values.
     *
     * @param yAlign
     * Y alignment. A number from 0 to 1. 0 aligns top edges, 1 aligns bottom
     * edges, and 0.5 centres vertically. Other values interpolate between
     * these values.
     *
     * @param rounding
     * Rounds the calculated values of <code>x</code>, <code>y</code>,
     * <code>width</code> and <code>height</code> to the nearest whole number.
     *
     * @param outRect
     * An optional instance to store the result in.  If not provided, a new
     * Rectangle is created.
     *
     * @return
     * The object containing the result of fitting <code>sourceRect</code> to
     * <code>targetRect</code>.
     */
    public static function fit(
        sourceRect:*, targetRect:*,
        fitMode:String,
        xAlign:Number = 0.5, yAlign:Number = 0.5,
        rounding:Boolean = false,
        outRect:* = null):*
    {
        // copy values to guard against aliasing
        var sw:Number = sourceRect.width, sh:Number = sourceRect.height;
        var tw:Number = targetRect.width, th:Number = targetRect.height;

        var scale:Number;

        if (!outRect) outRect = new Rectangle();

        if (fitMode == FitMode.OUTSIDE)
        {
