Line

Extends :: Obj

A class that defines a line with two coordinates The position vector pos and endPos.

This class must be accessed through the iio package.

 

Constructors

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

iio.Line( Vector: v1, v2 )

iio.Line( Number: x1, y1, x2, y2 )

iio.Line( Number: x1, y1, Vector v2 )

iio.Line( Vector v1, Number: x2, y2 )

- Creates a line starting at the first given vector and ending at the second given vector. The default value for any undefined coordinate is 0.

var l1 = new iio.Line();

var l2 = new iio.Line(0,0,io.canvas.width,io.canvas.height);

var topRight = new iio.Vec(io.canvas.width,0);
var l3 = new iio.Line(topRight,io.canvas.center);

var l4 = new iio.Line(0,io.canvas.height,topRight);

var l5 = new iio.Line(io.canvas.center,0,0);
 

Inherited Properties

Line :: Obj

Obj.pos :: ioVec

Obj.rotation :: 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

 

Properties

The new data added by the Line class.

 

.endPos :: Vec

- the end position of this line.

//get a line's endPos
var end = line.endPos;
 

Inherited Functions

Line :: Obj

Obj.setPos

Obj.translate

Obj.rotate

 

Graphics Functions

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

 

Functions

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

 

.clone()

:: Returns Line

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

//clone a line
var lineClone = line.clone();
 

.set( Line line )

.set( Vector: v1, v2 )

.set( Number: x1, y1, x2, y2 )

:: Returns this

- sets this line's start and end positions to the given coordinates.

//change a line's position properties
line.set(10,10,50,50);
 

.setEndPos( Vector point )

.setEndPos( Number: x, y )

:: Returns this

- sets the end position of this line to the given vector.

//change a line's end position
line.set(50,50);

//change it again
line.set(io.canvas.center);