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.
| Method | Description |
|---|---|
| camera | Set explicit camera parameters for this layer. |
| createCamera | Create and activate a camera initialized from this layer's camera state. |
| lookAt | Update this layer camera's target and optional up vector. |
| ortho | Enable orthographic projection for this layer. |
| perspective | Enable perspective projection for this layer. |
| resetCamera | Reset this layer to default auto camera behavior. |
| setCamera | Activate a camera for this layer. |
Compositing & visibility
Adjust the layer's opacity, blend mode, position, and rotation.
| Method | Description |
|---|---|
| blendMode | Set or get this layer's blend mode. |
| offset | Set or get this layer's compositing offset in pixels. |
| opacity | Set or get this layer's opacity. |
| rotateZ | Set or get this layer's compositing rotation in degrees. |
Grid, fonts & glyphs
Configure the layer-specific grid and glyph source.
| Method | Description |
|---|---|
| fontSize | Get or set this layer's font size. |
| 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. |
| useTileColors | Configure authored tileset color preservation for this layer. |
Layer lifecycle
Set a layer's drawing callbacks and control whether it is visible.
| Method | Description |
|---|---|
| draw | Set this layer's draw callback. |
| hide | Hide this layer from rendering. |
| isVisible | Check whether this layer is visible for rendering. |
| postDraw | Set this layer's post-draw callback. |
| show | Show this layer for rendering. |
Render outputs
Read the layer's texture, dimensions, and intermediate framebuffers.
| 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. |