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, filters, 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 extend TextmodeLayer with additional methods using the plugin API's extendLayer function. For example, the textmode-synth plugin adds a .synth() method for hydra-like procedural generation.

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

Accessors

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.

Methods

MethodDescription
blendModeSet or get this layer's blend mode.
cameraSet explicit camera parameters for this layer.
createCameraCreate and activate a camera initialized from this layer's camera state.
deletePluginStateDelete plugin-specific state from this layer.
drawSet this layer's draw callback.
filterQueue a post-processing filter for this layer.
fontSizeGet or set this layer's font size.
getPluginStateRetrieve plugin-specific state stored on this layer.
hasPluginStateCheck whether plugin-specific state exists on this layer.
hideHide this layer from rendering.
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.
lookAtUpdate this layer camera's target and optional up vector.
offsetSet or get this layer's compositing offset in pixels.
opacitySet or get this layer's opacity.
orthoEnable orthographic projection for this layer.
perspectiveEnable perspective projection for this layer.
postDrawSet this layer's post-draw callback.
resetCameraReset this layer to default auto camera behavior.
rotateZSet or get this layer's compositing rotation in degrees.
setCameraActivate a camera for this layer.
setPluginStateStore plugin-specific state on this layer. Plugins can use this to attach their own data to layer instances.
showShow this layer for rendering.
useTileColorsConfigure authored tileset color preservation for this layer.