Skip to content

textmode.js / layering / TextmodeLayer

Class: TextmodeLayer

A single layer within a multi-layered textmode rendering context.

Each layer has its own draw callback, grid, glyph source, camera state, opacity, blend mode, offset, and rotation.

Draw on a layer by providing a callback, similar to Textmodifier.draw on the base layer.

Plugins can add instance-safe methods and accessors with context.defineExtension('layer', ...).

The base layer, which is always present at the bottom of the layer stack, can be accessed via Textmodifier.layers as t.layers.base.

Cameras & projection

Create and configure the camera used while rendering this layer.

MethodDescription
cameraSet explicit camera parameters for this layer.
createCameraCreate and activate a camera initialized from this layer's camera state.
lookAtUpdate this layer camera's target and optional up vector.
orthoEnable orthographic projection for this layer.
perspectiveEnable perspective projection for this layer.
resetCameraReset this layer to default auto camera behavior.
setCameraActivate a camera for this layer.

Compositing & visibility

Adjust the layer's opacity, blend mode, position, and rotation.

MethodDescription
blendModeSet or get this layer's blend mode.
offsetSet or get this layer's compositing offset in pixels.
opacitySet or get this layer's opacity.
rotateZSet or get this layer's compositing rotation in degrees.

Grid, fonts & glyphs

Configure the layer-specific grid and glyph source.

MethodDescription
fontSizeGet or set this layer's font size.
loadFontLoad a font into this layer from a URL/path or existing TextmodeFont.
loadTilesetLoad a tileset into this layer from options or an existing TextmodeTileset.
useTileColorsConfigure authored tileset color preservation for this layer.

Layer lifecycle

Set a layer's drawing callbacks and control whether it is visible.

MethodDescription
drawSet this layer's draw callback.
hideHide this layer from rendering.
isVisibleCheck whether this layer is visible for rendering.
postDrawSet this layer's post-draw callback.
showShow this layer for rendering.

Render outputs

Read the layer's texture, dimensions, and intermediate framebuffers.

AccessorDescription
asciiFramebufferFramebuffer containing this layer's rendered textmode output.
drawFramebufferDraw framebuffer for this layer.
fontFont or tileset used by this layer.
gridGrid associated with this layer.
heightHeight of the final ASCII framebuffer in pixels.
textureWebGL texture of the final ASCII framebuffer.
widthWidth of the final ASCII framebuffer in pixels.