Skip to content

textmode.js / conversion / TextmodeConversionStrategy

Interface: TextmodeConversionStrategy ​

Interface for defining a custom textmode conversion strategy.

A conversion strategy defines how a source image is converted into textmode attributes (glyph index, charColor, cellColor) via a custom shader.

To register a custom strategy, implement this interface and pass it to TextmodeConversionManager.register.

Properties ​

PropertyModifierTypeDescription
idreadonlystringUnique identifier for this conversion strategy. This ID is used to select the strategy via TextmodeSource.conversionMode.

Methods ​

createShader() ​

ts
createShader(context): TextmodeShader;

Create the shader program for this conversion strategy. Called once when the strategy is first used for a given source.

The shader must output to 3 MRT attachments:

  • location 0: Character data (R=glyph index, G=unused, B=unused, A=unused)
  • location 1: charColor (RGBA)
  • location 2: cellColor (RGBA)

Parameters ​

ParameterTypeDescription
contextTextmodeConversionContextThe conversion context containing renderer and source information.

Returns ​

TextmodeShader

The compiled GLShader instance.

Example ​


createUniforms() ​

ts
createUniforms(context): Record<string, unknown>;

Create uniform values for this conversion strategy. Called every frame before rendering the conversion pass.

Use this to pass dynamic values (like time or source texture) to your shader.

Parameters ​

ParameterTypeDescription
contextTextmodeConversionContextThe conversion context containing renderer and source information.

Returns ​

Record<string, unknown>

An object mapping uniform names to values.

Example ​