Package | starling.utils |
Class | public class RectangleUtil |
Inheritance | RectangleUtil Object |
Method | Defined By | ||
---|---|---|---|
compare(r1:Rectangle, r2:Rectangle, e:Number = 0.0001):Boolean [static] Compares all properties of the given rectangle, returning true only if
they are equal (with the given accuracy 'e'). | RectangleUtil | ||
extend(rect:Rectangle, left:Number = 0, right:Number = 0, top:Number = 0, bottom:Number = 0):void [static] Extends the rectangle in all four directions. | RectangleUtil | ||
extendToWholePixels(rect:Rectangle, scaleFactor:Number = 1):void [static] Extends the rectangle in all four directions so that it is exactly on pixel bounds. | RectangleUtil | ||
fit(rectangle:Rectangle, into:Rectangle, scaleMode:String = showAll, pixelPerfect:Boolean = false, out:Rectangle = null):Rectangle [static] Calculates a rectangle with the same aspect ratio as the given 'rectangle',
centered within 'into'. | RectangleUtil | ||
getBounds(rectangle:Rectangle, matrix:Matrix, out:Rectangle = null):Rectangle [static] Calculates the bounds of a rectangle after transforming it by a matrix. | RectangleUtil | ||
getBoundsProjected(rectangle:Rectangle, matrix:Matrix3D, camPos:Vector3D, out:Rectangle = null):Rectangle [static] Calculates the bounds of a rectangle projected into the XY-plane of a certain 3D space
as they appear from the given camera position. | RectangleUtil | ||
getPositions(rectangle:Rectangle, out:Vector.<Point> = null):Vector.<Point> [static] Returns a vector containing the positions of the four edges of the given rectangle. | RectangleUtil | ||
intersect(rect1:Rectangle, rect2:Rectangle, out:Rectangle = null):Rectangle [static] Calculates the intersection between two Rectangles. | RectangleUtil | ||
normalize(rect:Rectangle):void [static] If the rectangle contains negative values for width or height, all coordinates
are adjusted so that the rectangle describes the same region with positive values. | RectangleUtil |
compare | () | method |
public static function compare(r1:Rectangle, r2:Rectangle, e:Number = 0.0001):Boolean
Compares all properties of the given rectangle, returning true only if they are equal (with the given accuracy 'e').
Parameters
r1:Rectangle | |
r2:Rectangle | |
e:Number (default = 0.0001 )
|
Boolean |
extend | () | method |
public static function extend(rect:Rectangle, left:Number = 0, right:Number = 0, top:Number = 0, bottom:Number = 0):void
Extends the rectangle in all four directions.
Parameters
rect:Rectangle | |
left:Number (default = 0 )
| |
right:Number (default = 0 )
| |
top:Number (default = 0 )
| |
bottom:Number (default = 0 )
|
extendToWholePixels | () | method |
public static function extendToWholePixels(rect:Rectangle, scaleFactor:Number = 1):void
Extends the rectangle in all four directions so that it is exactly on pixel bounds.
Parameters
rect:Rectangle | |
scaleFactor:Number (default = 1 )
|
fit | () | method |
public static function fit(rectangle:Rectangle, into:Rectangle, scaleMode:String = showAll, pixelPerfect:Boolean = false, out:Rectangle = null):Rectangle
Calculates a rectangle with the same aspect ratio as the given 'rectangle', centered within 'into'.
This method is useful for calculating the optimal viewPort for a certain display size. You can use different scale modes to specify how the result should be calculated; furthermore, you can avoid pixel alignment errors by only allowing whole-number multipliers/divisors (e.g. 3, 2, 1, 1/2, 1/3).
Parameters
rectangle:Rectangle | |
into:Rectangle | |
scaleMode:String (default = showAll )
| |
pixelPerfect:Boolean (default = false )
| |
out:Rectangle (default = null )
|
Rectangle |
See also
getBounds | () | method |
public static function getBounds(rectangle:Rectangle, matrix:Matrix, out:Rectangle = null):Rectangle
Calculates the bounds of a rectangle after transforming it by a matrix.
If you pass an out
-rectangle, the result will be stored in this rectangle
instead of creating a new object.
Parameters
rectangle:Rectangle | |
matrix:Matrix | |
out:Rectangle (default = null )
|
Rectangle |
getBoundsProjected | () | method |
public static function getBoundsProjected(rectangle:Rectangle, matrix:Matrix3D, camPos:Vector3D, out:Rectangle = null):Rectangle
Calculates the bounds of a rectangle projected into the XY-plane of a certain 3D space as they appear from the given camera position. Note that 'camPos' is expected in the target coordinate system (the same that the XY-plane lies in).
If you pass an 'out' Rectangle, the result will be stored in this rectangle instead of creating a new object.
Parameters
rectangle:Rectangle | |
matrix:Matrix3D | |
camPos:Vector3D | |
out:Rectangle (default = null )
|
Rectangle |
getPositions | () | method |
public static function getPositions(rectangle:Rectangle, out:Vector.<Point> = null):Vector.<Point>
Returns a vector containing the positions of the four edges of the given rectangle.
Parameters
rectangle:Rectangle | |
out:Vector.<Point> (default = null )
|
Vector.<Point> |
intersect | () | method |
public static function intersect(rect1:Rectangle, rect2:Rectangle, out:Rectangle = null):Rectangle
Calculates the intersection between two Rectangles. If the rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0.
Parameters
rect1:Rectangle | |
rect2:Rectangle | |
out:Rectangle (default = null )
|
Rectangle |
normalize | () | method |
public static function normalize(rect:Rectangle):void
If the rectangle contains negative values for width or height, all coordinates are adjusted so that the rectangle describes the same region with positive values.
Parameters
rect:Rectangle |