Name
CRC.fillText() — draws text
Synopsis
void fillText(Stringtext, floatx, floaty,floatmax)
Arguments
textThe text to draw in the canvas.
x, yThe “anchor point” of the text in the canvas. The interpretation of this point depends on the values of the
textAlignandtextBaselineproperties.maxThis optional argument specifies a maximum width for the text. If the
textwould be wider thanmaxwhen drawn using thefontproperty and the current transformation, then the text will be drawn using a smaller or more condensed version of the font instead.
Description
fillText() draws
text using the current
font and fillStyle properties. The
x and y arguments
specify where on the canvas the text should be drawn, but the
interpretation of these arguments depends on the
textAlign and textBaseline
properties, respectively.
If textAlign is “left” or is “start” (the
default) for a canvas that uses left-to-right text (also the default) or
“end” for a canvas that uses right-to-left text, then the text is drawn
to the right of the specified X coordinate. If
textAlign is “center”, then the text is horizontally
centered around the specified X coordinate. Otherwise (if
textAlign is “right”, is “end” for left-to-right
text, or is “start” for right-to-left text) the text is drawn to the
left of the specified X coordinate.
If textBaseline is “alphabetic” (the default),
“bottom”, or “ideographic”, most of the glyphs will appear above the
specified Y coordinate. If textBaseline is “center”, the text will be approximately ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access