| Package | graphics.geom |
| Class | public class AspectRatio |
| Inheritance | AspectRatio Dimension Object |
| Implements | Geometry, Lockable |
AspectRatio class encapsulates the width and height
of an object and indicates this aspect ratio.
The aspect ratio of an image is the ratio of its width to its height. For example, a standard NTSC television set uses an aspect ratio of 4:3, and an HDTV set uses an aspect ratio of 16:9. A computer monitor with a resolution of 640 by 480 pixels also has an aspect ratio of 4:3. A square has an aspect ratio of 1:1.
Note :This class use integers to specified the aspect ratio.
Example :
import graphics.geom.AspectRatio ;
var ar:AspectRatio ;
trace("------ AspectRatio(320,240)") ;
ar = new AspectRatio(320,240) ;
trace(ar) ; // 4:3
ar.verbose = true ;
trace(ar) ; // [AspectRatio width:320, height:240, ratio:{4:3}]
ar.lock() ;
ar.width = 640 ;
trace(ar) ; // [AspectRatio width:640, height:480, ratio:{4:3}]
ar.height = 120 ;
trace(ar) ; // [AspectRatio width:160, height:120, ratio:{4:3}]
ar.unlock() ;
ar.width = 320 ;
trace(ar) ; // [AspectRatio width:320, height:120, ratio:{8:3}]
trace("------ AspectRatio(1680,1050)") ;
ar = new AspectRatio(1680,1050) ;
trace(ar) ; // 8:5
ar.verbose = true ;
trace(ar) ; // [AspectRatio width:1680, height:1050, ratio:{8:5}]
trace("------ AspectRatio(0,0)") ;
ar = new AspectRatio(0) ;
trace(ar) ; // 0:0
ar.verbose = true ;
trace(ar) ; // [AspectRatio width:0, height:0, ratio:{0:0}]
| Property | Defined By | ||
|---|---|---|---|
| gcd : int [read-only]
Determinates the greatest common divisor if the current object. | AspectRatio | ||
![]() | height : Number
Determinates the height value of this instance. | Dimension | |
| verbose : Boolean
Indicates the verbose mode used in the toString() method. | AspectRatio | ||
![]() | width : Number
Determinates the width value of this instance. | Dimension | |
![]() | ZERO : Dimension [static]
Defines the Dimension object with the width and height properties set to zero. | Dimension | |
| Method | Defined By | ||
|---|---|---|---|
AspectRatio(width:int = 0, height:int = 0, lock:Boolean = false)
Creates a new AspectRatio instance. | AspectRatio | ||
clone():* [override]
Creates and returns a shallow copy of the object. | AspectRatio | ||
![]() |
Decreases the size by s and return its self(this). | Dimension | |
equals(o:*):Boolean [override]
Compares the specified object with this object for equality. | AspectRatio | ||
![]() | getBounds(x:Number, y:Number):Rectangle
Returns a new bounds with this size with a pos. | Dimension | |
![]() |
Increases the size by s and return its self(this). | Dimension | |
isLocked():Boolean
Returns true if the object is locked. | AspectRatio | ||
lock():void
Locks the object. | AspectRatio | ||
![]() | setSize(w:Number, h:Number):void
Sets the size of this instance. | Dimension | |
![]() | toObject():Object
Returns the Object representation of this object. | Dimension | |
toSource(indent:int = 0):String [override]
Returns the source code string representation of the object. | AspectRatio | ||
toString():String [override]
Returns the string representation of this instance. | AspectRatio | ||
unlock():void
Unlocks the object. | AspectRatio | ||
| gcd | property |
gcd:int [read-only] Determinates the greatest common divisor if the current object.
This property cast the width and the height Number in two int objects to calculate the value.
The floating values are ignored and convert in integers.
public function get gcd():int| verbose | property |
public var verbose:BooleanIndicates the verbose mode used in the toString() method.
| AspectRatio | () | Constructor |
public function AspectRatio(width:int = 0, height:int = 0, lock:Boolean = false)
Creates a new AspectRatio instance.
width:int (default = 0) — The width int value use to defines the aspect ratio value.
| |
height:int (default = 0) — The height int value use to defines the aspect ratio value.
| |
lock:Boolean (default = false) — This boolean flag indicates if the aspect ratio must be keeped when the width or height values changes.
|
| clone | () | method |
override public function clone():*Creates and returns a shallow copy of the object.
Returns* — A new object that is a shallow copy of this instance.
|
| equals | () | method |
override public function equals(o:*):BooleanCompares the specified object with this object for equality.
Compares the toString() (ex:4:3) of the aspect ratio object and the passed-in object type.
Example :
import graphics.geom.AspectRatio ;
var a:= new AspectRatio( 320 , 240 ) ;
var b:= new AspectRatio( 640 , 480 ) ;
trace( a.equals( b ) ) ; // true
Parameters
o:* |
Boolean — true if the the specified object is equal with this object.
|
| isLocked | () | method |
public function isLocked():Boolean
Returns true if the object is locked.
Boolean — true if the object is locked.
|
| lock | () | method |
public function lock():voidLocks the object.
| toSource | () | method |
override public function toSource(indent:int = 0):StringReturns the source code string representation of the object.
Parameters
indent:int (default = 0) |
String — the source code string representation of the object.
|
| toString | () | method |
override public function toString():StringReturns the string representation of this instance.
ReturnsString — the string representation of this instance.
|
| unlock | () | method |
public function unlock():voidUnlocks the object.