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
Related References
textToContours
Returns an array of arrays of points outlining a string of text written using the font.
textToModel
Converts text into a 3D model that can be rendered in WebGL mode.
textToPaths
Returns a flat array of path commands that describe the outlines of a string of text.
textToPoints
Returns an array of points outlining a string of text written using the font.