Text

Extends :: Obj

A class that defines a text object with a position vector and style properties.

This class must be accessed through the iio package.

 

Constructors

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

Text( String text, Vector pos )

Text( String text, Number: x, y )

- creates a text object at the specified position with the given string.

//create text that says 'hello iio' at canvas center
var text = new iio.Text('hello iio', io.canvas.center);
 

Inherited Properties

Text :: ioShape :: 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

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

 

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

 

Properties

The new data added by the Text class. These properties will always exist for an instantiated Text object.

 

.text :: String

- the text of this text object.

//get a text object's text
var message = text.text;

//set a text object's message directly
text.text = 'new message'; 
 

.font :: String

- the font and font size of this text object.

//get a text object's font
var f = text.font;

//set font directly
text.font = '30px Arial';
 

.textAlign :: String

- the alignment of this text object. Possible values are 'center', 'right', and 'left'. The default value is 'left'.

//get a text object's textAlign
var f = text.textAlign;

//set the text aligment
text.textAlign = 'center';
 

Inherited Functions

Text :: ioShape :: Obj

Obj.setPos

Obj.translate

Obj.rotate

 

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 Text class, and available to all instantiated Text objects.

 

.clone()

:: Returns Text

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

//clone a text object
var t2 = text.clone();
 

.setText( String text )

:: Returns this

- sets the text of this text object to the given message.

//change the text
text.setText('new text');
 

.setFont( String text )

:: Returns this

- sets the font and font size of this text object.

//change the font and size
text.setFont('30px Consolas');
 

.setTextAlign( String text )

:: Returns this

- sets the text alignment of this text object. Possible values are 'center', 'right', and 'left'. The default value is 'left'.

//change the text
text.setTextAlign('center');