Skip to content

textmode.js / TextmodeGrid

Class: TextmodeGrid

Grid used by a textmode layer.

The grid determines how characters are positioned and sized. By default, it is responsive and recalculates columns and rows from the canvas size and glyph cell size.

You can manually set cols and rows to lock the grid to a specific size.

Example

Accessors

AccessorDescription
cellHeightHeight of each cell in screen pixels.
cellWidthWidth of each cell in screen pixels.
colsNumber of columns in the grid.
heightTotal grid height in screen pixels.
offsetXHorizontal offset in pixels from the canvas edge to the grid.
offsetYVertical offset in pixels from the canvas edge to the grid.
rowsNumber of rows in the grid.
widthTotal grid width in screen pixels.

Methods

MethodDescription
resetRecalculate columns and rows from the current canvas and cell dimensions.
responsiveRestore responsive sizing so subsequent canvas resizes recompute columns and rows.