forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscale.as
More file actions
20 lines (16 loc) · 710 Bytes
/
scale.as
File metadata and controls
20 lines (16 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package utils.ratio {
import flash.geom.Rectangle;
import utils.math.Percent;
/**
* Scales an area's width and height while preserving aspect ratio.
* @param rect Area's width and height expressed as a Rectangle - the Rectangle's x and y values are ignored
* @param amount Amount you wish to scale by
* @param snapToPixel true to force the scale to whole pixels, or false to allow sub-pixels
* @author Aaron Clinger
* @author Shane McCartney
* @author David Nelson
*/
public function scale(rect:Rectangle, amount:Percent, snapToPixel:Boolean = true):Rectangle {
return defineRect(rect, rect.width * amount.decimalPercentage, rect.height * amount.decimalPercentage, snapToPixel);
}
}