Reference textAlign()

textAlign()

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

horizAlign
Constant:

horizontal alignment, either LEFT, CENTER, or RIGHT.

vertAlign
Constant:

vertical alignment, either TOP, BOTTOM, CENTER, or BASELINE.

Notice any errors or typos? Please let us know. Please feel free to edit src/typography/attributes.js and open a pull request!

Related References