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])
Parameters
horizAlign
LEFT|CENTER|RIGHT: horizontal alignment
vertAlign
TOP|BOTTOM|CENTER|BASELINE: vertical alignment
Notice any errors or typos? Please let us know. Please feel free to edit src/type/textCore.js and open a pull request!