Packagepegas.geom
Classpublic class Rectangle
InheritanceRectangle Inheritance Dimension

The Rectangle class is used to create and modify Rectangle objects.

A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y), and by its width and its height.

The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of one property has no effect on the others.

To used this class with a FP8 and > with flash.display.BitmapData class and other flash.classes you can use the method toFlash() to return a compatible reference of this object.



Public Properties
 PropertyDefined by
  bottom : Number
Returns the sum of the y and height properties.
Rectangle
  bottomLeft : Vector2
Returns the location of the Rectangle object's bottom-left corner, determined by the values of the x and y properties.
Rectangle
  bottomRight : Vector2
Returns the location of the Rectangle object's bottom-right corner, determined by the values of the x and y properties.
Rectangle
  center : Vector2
Returns the location of the Rectangle object's center, determined by the values of the x and y properties.
Rectangle
 Inheritedheight : Number
Determinates the height value of this instance.
Dimension
  left : Number
Returns the x coordinate of the top-left corner of the rectangle.
Rectangle
  right : Number
[read-only] Returns the sum of the x and width properties.
Rectangle
  size : Vector2
Returns the size of the Rectangle object, expressed as a Vector2 object with the values of the width and height properties.
Rectangle
  top : Number
Returns the y coordinate of the top-left corner of the rectangle.
Rectangle
  topLeft : Vector2
Returns the location of the Rectangle object's top-left corner determined by the x and y values of the point.
Rectangle
  topRight : Vector2
Returns the location of the Rectangle object's top-right corner determined by the x and y values of the point.
Rectangle
 Inheritedwidth : Number
Determinates the width value of this instance.
Dimension
  x : Number
The x coordinate of the top-left corner of the rectangle.
Rectangle
  y : Number
The y coordinate of the top-left corner of the rectangle.
Rectangle
 InheritedZERO : Dimension
[static] Defines the Dimension object with the width and height properties set to zero.
Dimension
Public Methods
 MethodDefined by
  
Rectangle(... arguments)
Creates a new Rectangle instance whose top-left corner is specified by the x and y parameters.
Rectangle
  
clone():*
Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.
Rectangle
  
compare(o1:*, o2:*):Number
[static] Compares its two arguments for order.
Rectangle
  
containsCoordinate(x:Number, y:Number):Boolean
Determines whether the specified point is contained within the rectangular region defined by this Rectangle object.
Rectangle
  
Determines whether the Rectangle object specified by the rect parameter is contained within this Rectangle object.
Rectangle
  
containsVector(vector:Vector2):Boolean
Determines whether the specified point is contained within the rectangular region defined by this Rectangle object.
Rectangle
 Inherited
Decreases the size by s and return its self(this).
Dimension
  
empty():void
Sets all of the Rectangle object's properties to 0.
Rectangle
  
equals(o:*):Boolean
Compares the specified object with this object for equality.
Rectangle
 Inherited
getBounds(x:Number, y:Number):Rectangle
Returns a new bounds with this size with a pos.
Dimension
 Inherited
Increases the size by s and return its self(this).
Dimension
  
inflate(dx:Number, dy:Number):void
Increases the size of the Rectangle object by the specified amounts.
Rectangle
  
inflatePoint(vector:Vector2):void
Increases the size of the Rectangle object.
Rectangle
  
If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, the intersection() method returns the area of intersection as a Rectangle object.
Rectangle
  
isEmpty():Boolean
Determines whether or not this Rectangle object is empty.
Rectangle
  
offset(dx:Number, dy:Number):void
Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts.
Rectangle
  
offsetPoint(vector:Vector2):void
Adjusts the location of the Rectangle object using a Point object as a parameter.
Rectangle
  
setRight(n:Number):void
Sets the sum of the x and width properties.
Rectangle
 Inherited
setSize(w:Number, h:Number):void
Sets the size of this instance.
Dimension
  
toFlash():Rectangle
Returns a flash.geom.Rectangle reference of this Rectangle object.
Rectangle
  
toObject():Object
Returns the Object representation of this object.
Rectangle
  
toSource(indent:int = 0):String
Returns the source code string representation of the object.
Rectangle
  
toString():String
Returns the string representation of the object.
Rectangle
  
Adds two rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two rectangles.
Rectangle
Property detail
bottomproperty
bottom:Number  [read-write]

Returns the sum of the y and height properties.

Implementation
    public function get bottom():Number
    public function set bottom(value:Number):void
bottomLeftproperty 
bottomLeft:Vector2  [read-write]

Returns the location of the Rectangle object's bottom-left corner, determined by the values of the x and y properties.

Implementation
    public function get bottomLeft():Vector2
    public function set bottomLeft(value:Vector2):void
bottomRightproperty 
bottomRight:Vector2  [read-write]

Returns the location of the Rectangle object's bottom-right corner, determined by the values of the x and y properties.

Implementation
    public function get bottomRight():Vector2
    public function set bottomRight(value:Vector2):void
centerproperty 
center:Vector2  [read-write]

Returns the location of the Rectangle object's center, determined by the values of the x and y properties.

Implementation
    public function get center():Vector2
    public function set center(value:Vector2):void
leftproperty 
left:Number  [read-write]

Returns the x coordinate of the top-left corner of the rectangle.

Implementation
    public function get left():Number
    public function set left(value:Number):void
rightproperty 
right:Number  [read-only]

Returns the sum of the x and width properties.

Implementation
    public function get right():Number
sizeproperty 
size:Vector2  [read-write]

Returns the size of the Rectangle object, expressed as a Vector2 object with the values of the width and height properties.

Implementation
    public function get size():Vector2
    public function set size(value:Vector2):void
topproperty 
top:Number  [read-write]

Returns the y coordinate of the top-left corner of the rectangle.

Implementation
    public function get top():Number
    public function set top(value:Number):void
topLeftproperty 
topLeft:Vector2  [read-write]

Returns the location of the Rectangle object's top-left corner determined by the x and y values of the point.

Implementation
    public function get topLeft():Vector2
    public function set topLeft(value:Vector2):void
topRightproperty 
topRight:Vector2  [read-write]

Returns the location of the Rectangle object's top-right corner determined by the x and y values of the point.

Implementation
    public function get topRight():Vector2
    public function set topRight(value:Vector2):void
xproperty 
public var x:Number

The x coordinate of the top-left corner of the rectangle.

yproperty 
public var y:Number

The y coordinate of the top-left corner of the rectangle.

Constructor detail
Rectangle()constructor
public function Rectangle(... arguments)

Creates a new Rectangle instance whose top-left corner is specified by the x and y parameters. If not arguments are passed-in the constructor an empty rectangle is created.

Parameters
... arguments — The x coordinate of the top-left corner of the rectangle.

Example
    import pegas.geom.Rectangle;
    var rec:Rectangle = new Rectangle(5, 10, 50, 100);
    trace( "output : " + rec.toString() ); // output : (x:5,y:10,width:50,height:100)
    

Method detail
clone()method
public override function clone():*

Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.

Returns
* — a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.
compare()method 
public static function compare(o1:*, o2:*):Number

Compares its two arguments for order.

Parameters
o1:* — the first object to compare.
 
o2:* — the second object to compare.

Returns
Number

  • -1 if o1 is "lower" than (less than, before, etc.) o2 ;
  • 1 if o1 is "higher" than (greater than, after, etc.) o2 ;
  • 0 if o1 and o2 are equal.

  • Throws
    — the arguments of the method must be Rectangle reference.
    containsCoordinate()method 
    public function containsCoordinate(x:Number, y:Number):Boolean

    Determines whether the specified point is contained within the rectangular region defined by this Rectangle object.

    Parameters
    x:Number — The x coordinate to check.
     
    y:Number — The y coordinate to check.

    Returns
    Booleantrue if the specified point is contained within the rectangular region defined by this Rectangle object.
    containsRectangle()method 
    public function containsRectangle(rec:Rectangle):Boolean

    Determines whether the Rectangle object specified by the rect parameter is contained within this Rectangle object.

    Parameters
    rec:Rectangle

    Returns
    Booleantrue if the specified Rectangle is contained within this Rectangle object.
    containsVector()method 
    public function containsVector(vector:Vector2):Boolean

    Determines whether the specified point is contained within the rectangular region defined by this Rectangle object.

    Parameters
    vector:Vector2 — The Vector2 to check.

    Returns
    Booleantrue if the specified point is contained within the rectangular region defined by this Rectangle object.
    empty()method 
    public function empty():void

    Sets all of the Rectangle object's properties to 0.

    equals()method 
    public override function equals(o:*):Boolean

    Compares the specified object with this object for equality.

    Parameters
    o:*

    Returns
    Booleantrue if the the specified object is equal with this object.
    inflate()method 
    public function inflate(dx:Number, dy:Number):void

    Increases the size of the Rectangle object by the specified amounts.

    Parameters
    dx:Number
     
    dy:Number
    inflatePoint()method 
    public function inflatePoint(vector:Vector2):void

    Increases the size of the Rectangle object.

    Parameters
    vector:Vector2
    intersection()method 
    public function intersection(toIntersect:Rectangle):Rectangle

    If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, the intersection() method returns the area of intersection as a Rectangle object.

    Parameters
    toIntersect:Rectangle

    Returns
    Rectangle
    isEmpty()method 
    public function isEmpty():Boolean

    Determines whether or not this Rectangle object is empty.

    Returns
    Booleantrue if the width and the height of the rectangle are empty (0).
    offset()method 
    public function offset(dx:Number, dy:Number):void

    Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts.

    Parameters
    dx:Number
     
    dy:Number
    offsetPoint()method 
    public function offsetPoint(vector:Vector2):void

    Adjusts the location of the Rectangle object using a Point object as a parameter.

    Parameters
    vector:Vector2
    setRight()method 
    public function setRight(n:Number):void

    Sets the sum of the x and width properties.

    Parameters
    n:Number
    toFlash()method 
    public function toFlash():Rectangle

    Returns a flash.geom.Rectangle reference of this Rectangle object.

    Returns
    Rectangle — a flash.geom.Rectangle reference of this Rectangle object.
    toObject()method 
    public override function toObject():Object

    Returns the Object representation of this object.

    Returns
    Object — the Object representation of this object.
    toSource()method 
    public override function toSource(indent:int = 0):String

    Returns the source code string representation of the object.

    Parameters
    indent:int (default = 0)

    Returns
    String — the source code string representation of the object.
    toString()method 
    public override function toString():String

    Returns the string representation of the object.

    Returns
    String — the string representation of the object.
    union()method 
    public function union(toUnion:Rectangle):Rectangle

    Adds two rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two rectangles.

    Parameters
    toUnion:Rectangle

    Returns
    Rectangle