drawText
Canonical ID: graphics.text. Nederlands: tekenTekst.
Draws Text at a logical-pixel anchor using a positive size. Optional font is sans or pixel; optional alignment is left, center, or right. Names ignore letter case and surrounding whitespace. The x coordinate is the selected horizontal anchor; y is the top of the line box. The pinned fonts are embedded in graphical builds. Only the color argument is normalized as a color, never the displayed content.
Signature
drawText(x, y, content, size, color)
drawText(x, y, content, size, color, font)
drawText(x, y, content, size, color, font, align)
Arguments
| Parameter | Type | Requirement |
|---|---|---|
x |
Number | Finite horizontal coordinate in logical pixels. |
y |
Number | Finite vertical coordinate in logical pixels. |
content |
Text | Text to display; convert numbers explicitly. |
size |
Number | Finite and greater than 0. |
color |
Text | Nonempty; use portable English/Dutch names or #RGB/#RRGGBB. |
font |
Text, optional | “sans” (default) or “pixel”. |
align |
Text, optional | “left” (default), “center”, or “right”; supply font first. |
Return value
None.
Example
# language: en
clearCanvas("black")
drawText(320, 100, "Pliro", 36, "wit", "pixel", "center")
drawText(320, 160, "Score: " + text(12), 20, "yellow", "sans", "center")
Two centered text labels.
Notes and common mistakes
Use the function name for your source language. Its canonical ID is a shared documentation label; you do not type that ID as a call. Giving your own variable or function the same name can hide the built-in. Supply the documented arguments and value types. Pliro reports mismatches when checking can detect them, or when the call runs.
A host is the app or environment running your program. To see a drawing, it needs a renderer, the part that draws on screen. The command-line command pliro run shows text but does not draw these graphics. The host support table explains which effects work in the IDE, browser, native app, and phone preview. A native build reports an unsupported capability instead of leaving it out.
2D uses a 640 × 360 scene with a top-left origin, +X right and +Y down. Both English and Dutch portable color names work in either syntax locale, as do #RGB and #RRGGBB. Other nonempty 2D color text is host-dependent.
Related entries
clearCanvas · rectangle · circle · drawLine · Programming guides · Host support · Calls and arguments
