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
| Accessor | Description |
|---|---|
| asciiFramebuffer | Framebuffer containing this layer's rendered textmode output. |
| drawFramebuffer | Draw framebuffer for this layer. |
| font | Font or tileset used by this layer. |
| grid | Grid associated with this layer. |
| height | Height of the final ASCII framebuffer in pixels. |
| texture | WebGL texture of the final ASCII framebuffer. |
| width | Width of the final ASCII framebuffer in pixels. |
Methods
| Method | Description |
|---|---|
| blendMode | Set or get this layer's blend mode. |
| camera | Set explicit camera parameters for this layer. |
| createCamera | Create and activate a camera initialized from this layer's camera state. |
| deletePluginState | Delete plugin-specific state from this layer. |
| draw | Set this layer's draw callback. |
| filter | Queue a post-processing filter for this layer. |
| fontSize | Get or set this layer's font size. |
| getPluginState | Retrieve plugin-specific state stored on this layer. |
| hasPluginState | Check whether plugin-specific state exists on this layer. |
| hide | Hide this layer from rendering. |
| loadFont | Load a font into this layer from a URL/path or existing TextmodeFont. |
| loadTileset | Load a tileset into this layer from options or an existing TextmodeTileset. |
| lookAt | Update this layer camera's target and optional up vector. |
| offset | Set or get this layer's compositing offset in pixels. |
| opacity | Set or get this layer's opacity. |
| ortho | Enable orthographic projection for this layer. |
| perspective | Enable perspective projection for this layer. |
| postDraw | Set this layer's post-draw callback. |
| resetCamera | Reset this layer to default auto camera behavior. |
| rotateZ | Set or get this layer's compositing rotation in degrees. |
| setCamera | Activate a camera for this layer. |
| setPluginState | Store plugin-specific state on this layer. Plugins can use this to attach their own data to layer instances. |
| show | Show this layer for rendering. |
| useTileColors | Configure authored tileset color preservation for this layer. |