Skip to content

textmode.js / plugins / TextmodePluginContext

Interface: TextmodePluginContext

Host-provided context passed to plugins when they are installed on a Textmodifier instance.

Extensions

Add and remove methods on layer and source instances.

MethodDescription
extendLayerExtend TextmodeLayer instances with a new method. The method will be available on all existing and future layer instances.
extendSourceExtend TextmodeSource instances with a new method. The method will be available on image, video, texture, and overlay sources.
removeLayerExtensionRemove a method extension from TextmodeLayer.
removeSourceExtensionRemove a method extension from TextmodeSource.

Host resources

Access the renderer, grid, glyph atlas, canvas, framebuffers, and layer manager.

asciiFramebuffer

ts
asciiFramebuffer: TextmodeFramebuffer;

The framebuffer containing the ASCII representation (from base layer).
This framebuffer only has a single attachment.


canvas

ts
canvas: TextmodeCanvasHandle;

A stable handle for the canvas used by the Textmodifier instance.


drawFramebuffer

ts
drawFramebuffer: TextmodeFramebuffer;

The framebuffer the user draws to with 3 attachments (from base layer).


font

ts
font: 
  | TextmodeFont
  | TextmodeTileset;

The active glyph source used by the Textmodifier instance (from base layer).


glyphAtlas

ts
glyphAtlas: TextmodeGlyphAtlas;

Backend-neutral glyph atlas used by the Textmodifier instance (from base layer).


grid

ts
grid: TextmodeGrid;

The grid used by the Textmodifier instance (from base layer).


layerManager

ts
layerManager: TextmodeLayerManager;

The layer manager for accessing and managing all layers.

Layer hooks

Register callbacks around individual layer renders and disposal.

MethodDescription
registerLayerDisposedHookRegister a callback to be invoked when a layer is about to be disposed.
registerLayerPostRenderHookRegister a callback to be invoked after each layer's render cycle. This happens after the user draw callback but before the ASCII resolve pass.
registerLayerPreRenderHookRegister a callback to be invoked before each layer's render cycle. This happens after the layer's visibility check but before any drawing operations. Useful for rendering content to the layer's framebuffer before user draw callbacks.

Sketch hooks

Register callbacks around setup and the sketch draw cycle.

MethodDescription
registerPostDrawHookRegister a callback to be invoked after each draw cycle. Happens outside of the draw framebuffer being bound after the final result is drawn to the screen.
registerPostSetupHookRegister a callback to be invoked after the user's setup callback completes. This happens after user code in setup() has finished executing, but before the loading screen finishes and the main render loop begins. Useful for plugins that need to finalize initialization after user setup.
registerPreDrawHookRegister a callback to be invoked before each draw cycle. Happens just before any framebuffer
registerPreSetupHookRegister a callback to be invoked before the user's setup callback runs. This happens after the Textmodifier and all layers are fully initialized, but before user code in setup() executes. Useful for plugins that need to prepare resources or state before user setup.