mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 17:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,43 @@
|
||||
package org.osmf.layout
|
||||
{
|
||||
import flash.geom.Point;
|
||||
|
||||
internal class ScaleModeUtils
|
||||
{
|
||||
|
||||
public function ScaleModeUtils()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function getScaledSize(scaleMode:String, availableWidth:Number, availableHeight:Number, intrinsicWidth:Number, intrinsicHeight:Number) : Point
|
||||
{
|
||||
var result:Point = null;
|
||||
var availableRatio:Number = NaN;
|
||||
var componentRatio:Number = NaN;
|
||||
switch(scaleMode)
|
||||
{
|
||||
case ScaleMode.ZOOM:
|
||||
case ScaleMode.LETTERBOX:
|
||||
availableRatio = availableWidth / availableHeight;
|
||||
componentRatio = (intrinsicWidth || availableWidth) / (intrinsicHeight || availableHeight);
|
||||
if(scaleMode == ScaleMode.ZOOM && componentRatio < availableRatio || scaleMode == ScaleMode.LETTERBOX && componentRatio > availableRatio)
|
||||
{
|
||||
result = new Point(availableWidth,availableWidth / componentRatio);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new Point(availableHeight * componentRatio,availableHeight);
|
||||
}
|
||||
break;
|
||||
case ScaleMode.STRETCH:
|
||||
result = new Point(availableWidth,availableHeight);
|
||||
break;
|
||||
case ScaleMode.NONE:
|
||||
result = new Point(intrinsicWidth || availableWidth,intrinsicHeight || availableHeight);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user