Rect

Extends :: Poly :: Shape :: Obj

A class that defines a rectangle with a position and 4 corner vertices. The position vector pos is at the center of the rectangle.

This class must be accessed through the iio package.

 

Constructors

These functions are used to instantiate new instances of the Rect class. Constructor functions must be preceded by the new keyword.

 

iio.Rect( Vector position, Number: width, height )

iio.Rect( Number x, y, width, height )

- creates a rectangle with the given position and dimensions. If the height is omitted, a square will be created with the width as its size.

- The default value for all parameters is 0.

//create a 60x60 square at canvas center
var square = new iio.Rect(io.canvas.center,60);

//create a 40x60 rectangle at 0,0
var rect = new iio.Rect(0,0,40,60);
 

Inherited Properties

Rect :: Poly :: Shape :: Obj

Obj.pos :: ioVec

Obj.rotation :: Number

Poly.vertices :: Array

Poly.width :: Number

Poly.height :: Number

Poly.originToLeft :: Number

Poly.originToTop :: Number

 

Graphics Properties

The following properties can are attached by the iio Graphics Engine. Note that these properties are 'undefined' by default, so you must define them with their set functions or set their values directly.

.styles.alpha :: Number

.styles.strokeStyle :: Color||Pattern||Gradient

.styles.lineWidth :: Number

.styles.shadow :: Object

.styles.fxFade :: Object

.styles.fillStyle :: Color||Pattern||Gradient

.img :: Image

.anims :: Array

.animKey :: Number

.animFrame :: Number

 

Kinematics Properties

The following properties can are attached by the iio Kinematics Engine. Note that these properties are 'undefined' by default, so you must define them with their set functions or set their values directly.

.vel :: Vec

.acc :: Vec

.torque :: Number

.shrinkRate :: Number

.bounds :: Object

 

Inherited Functions

Rect :: Poly :: Shape :: Obj

Obj.setPos

Obj.translate

Obj.rotate

Poly.contains

Poly.getTrueVertices

Poly.left

Poly.right

Poly.top

Poly.bottom

 

Graphics Functions

The following functions can are attached by the iio Graphics Engine.

 

Kinematics Functions

The following functions can are attached by the iio Kinematics Engine. Note that you must call the enableKinematics function before you can utilize any of these functions.

 

Functions

These functions are added by the Rect class, and available to all instantiated Rect objects.

 

.clone()

:: Returns Rect

- returns a new Rect with the same properties as this one. Makes a hard copy of the object.

 

.setSize( Vector size )

.setSize( Number: w, h )

:: Returns this

- sets the dimensions of this rectangle to the given width and height. The default value for both parameter is 0

//change the size of a rectangle
rect.setSize(20,40);