Skip to main content

Printing Text

For writing text on the screen.

print​

Print text to the screen.

At a specific position on the screen with overflow wrapping​

print(text, x, y, limit, align, rotation, scaleX, scaleY, originX, originY, shearX, shearY)
ParameterTypeDefaultNote
textstring⚠️ required
xnumber⚠️ required
ynumber⚠️ required
limitnumber⚠️ requiredwrap the line after this many horizontal pixels.
alignstring'left'enum: 'left', 'center', 'right'.
rotationnumber0in radians.
scaleXnumber1
scaleYnumber1
originXnumber0
originYnumber0
shearXnumber0
shearYnumber0

At a specific position on the screen without overflow wrapping​

print(text, x, y, false, false, rotation, scaleX, scaleY, originX, originY, scaleX, scaleY)
ParameterTypeDefaultNote
textstring⚠️ required
xnumber⚠️ required
ynumber⚠️ required
falsebooleanℹ️ literal
falsebooleanℹ️ literal
rotationnumber0in radians.
scaleXnumber1
scaleYnumber1
originXnumber0
originYnumber0
shearXnumber0
shearYnumber0

In a terminal fashion​

print(text)
ParameterTypeDefaultNote
textstring⚠️ required

In a terminal fashion with a new line​

print(text, false)
ParameterTypeDefaultNote
textstring⚠️ required
falsebooleanℹ️ literal

In a terminal fashion without wrapping nor new line​

print(text, false, true)
ParameterTypeDefaultNote
textstring⚠️ required
falsebooleanℹ️ literal
truebooleanℹ️ literal

printBackspace​

Delete the last printed character via the 3rd and 4th variants of print() and update the cursor position.

Delete the last character​

printBackspace(colorId)
ParameterTypeDefaultNote
colorIdnumberactive colorinteger in range [-1, 15] where -1 would indicate transparent background.

Delete the last character without doing a carriage return​

By default, a carriage return is done when the start of line is reached. This disables that behaviour.

printBackspace(colorId, true)
ParameterTypeDefaultNote
colorIdnumberactive colorinteger in range [-1, 15] where -1 would indicate transparent background.
truebooleanℹ️ literal

printCursor​

Change the print cursor position used by print() when in terminal fashion.

The positions are on a characters grid, the size of the grid can be requested from termSize().

Set cursor position​

printCursor(x, y, backgroundColorId)
ParameterTypeDefaultNote
xnumbercurrent postition
ynumbercurrent position
backgroundColorIdnumbercurrent background colorinteger in range [-1, 15] where -1 would indicate transparent background.

Get cursor position​

x, y, backgroundColorId = printCursor()
ReturnTypeNote
xnumber
ynumber
backgroundColorIdnumberinteger in range [-1, 15] where -1 would indicate transparent background.

wrapText​

Get formatting information for text, given a wrap limit.

This function accounts for newlines correctly (i.e. '\n').

width, wrappedText = wrapText(text, wrapLimit)
ParameterTypeDefaultNote
textstring⚠️ required
wrapLimitnumber⚠️ required
ReturnTypeNote
widthnumberthe maximum width of the wrapped text.
wrappedTexttable string[]list of text lines.