Text
Like the shape functions, the text functions create a new object and add it to the stage. By default, it is centered at the specified x and y coordinates. This can be changed by setting the textAlign and textBaseline properties.
For a font to be used, but must be installed on the computer, or imported into the web page using webfonts. For this reason it may be best to stick to web safe fonts. These are fonts that are likely to be installed on all computers.
Writing Text
write(x, y, text)
Writes a string of text at the specified x and y coordinates. By default the text is centered at the specified coordinates. This can by changed using the textAlign and textBaseline properties.
Parameters
- x Number x coordinate.
- y Number y coordinate.
- text String Text to display.
Returns
TextLive Text
display(x, y, expression)
Similar to write, except that if a variable name is passed as the third parameter, it will always display the current value of the variable.
Parameters
- x Number x coordinate.
- y Number y coordinate.
- expression Expression Variable or expression to display.
Returns
TextProperties
object.fill
A String
defining the text's fill color. This can be a
known named color such as "red", "blue", etc., a hexidecimal color
code in the format #rrbbgg
or the individual rgb values
in the format rgb(red, green, blue)
.
object.font
A String
defining the font used. The font must be installed
on the computer, or embedded as a webfont.
object.fontSize
A Number
defining the size of the text in pixels.
object.textAlign
A String
defining the horizontal alignment of the text.
Accepted values are "left", "right" and "center". The default is
"center".
object.textBasline
A String
defining the vertical alignment of the text.
Accepted values are "top", "middle", "bottom" and "alphabetic".
The default is "middle".