textAlign()
Set how text is aligned
This function controls the alignment of the text you create with the text() function. It basically tell the computer how to understand the x, y
coordinates the text
function takes as parameter, since the text is not a point anyway.
When you say textAlign(RIGHT)
then call text("Hello", x, y)
the right edge of the word "Hello" becomes the x
value you give in the text function.
Same thing with the vertical alignment, If you use textAlign(RIGHT, TOP)
, the top right corner becomes the x, y
coordinates you give in the text function.
You need to use on the predefined constants specified below.
horizAlign
Specifies the horizontal alignment, takes values CENTER, RIGHT, LEFT
vertAlign
Specifies the vertical alignment, takes values CENTER, TOP, BOTTOM, BASELINE
Examples
Find these documents helpful? Let the people who made them help your child learn to code at Strivemath!
We'd love to hear your Feedback/Comments here.
Last updated