Sets the way text is aligned when text() is called.
By default, calling text('hi', 10, 20)
places the bottom-left corner of the text's bounding box at (10, 20).
The first parameter, horizAlign
, changes the way text() interprets x-coordinates. By default, the x-coordinate sets the left edge of the bounding box. textAlign()
accepts the following values for horizAlign
: LEFT
, CENTER
, or RIGHT
.
The second parameter, vertAlign
, is optional. It changes the way text() interprets y-coordinates. By default, the y-coordinate sets the bottom edge of the bounding box. textAlign()
accepts the following values for vertAlign
: TOP
, BOTTOM
, CENTER
, or BASELINE
.
Examples
Syntax
textAlign(horizAlign, [vertAlign])
textAlign()
Parameters
horizontal alignment, either LEFT, CENTER, or RIGHT.
vertical alignment, either TOP, BOTTOM, CENTER, or BASELINE.