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
| Property | Modifier | Type | Description |
|---|---|---|---|
id | readonly | string | Unique identifier for this conversion strategy. This ID is used to select the strategy via TextmodeSource.conversionMode. |
Methods
createShader()
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
| Parameter | Type | Description |
|---|---|---|
context | TextmodeConversionContext | The conversion context containing renderer and source information. |
Returns
The compiled GLShader instance.
Example
createUniforms()
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
| Parameter | Type | Description |
|---|---|---|
context | TextmodeConversionContext | The conversion context containing renderer and source information. |
Returns
Record<string, unknown>
An object mapping uniform names to values.