Skip to content

textmode.js / conversion / TextmodeConversionManager

Class: TextmodeConversionManager ​

Registers conversion strategies for a Textmodifier instance.

Access via Textmodifier.conversions.

Example ​

ts
// Register a custom conversion strategy
t.conversions.register({
    id: 'custom',
    createShader: (ctx) => shader,
    createUniforms: (ctx) => ({ u_image: ctx.source.texture })
});

// Use the conversion mode on an image
img.conversionMode('custom');

Methods ​

has() ​

ts
has(id): boolean;

Check if a conversion strategy with the given ID is registered.

Parameters ​

ParameterTypeDescription
idstringThe conversion strategy ID to check

Returns ​

boolean

true if the strategy exists

Example ​


register() ​

ts
register(strategy): void;

Register a custom conversion strategy.

Parameters ​

ParameterTypeDescription
strategyTextmodeConversionStrategyThe conversion strategy to register

Returns ​

void

Example ​

ts
t.conversions.register({
    id: 'custom',
    createShader: (ctx) => shader,
    createUniforms: (ctx) => ({ u_image: ctx.source.texture })
});

unregister() ​

ts
unregister(id): boolean;

Unregister a conversion strategy by its ID.

Parameters ​

ParameterTypeDescription
idstringThe conversion strategy ID to unregister

Returns ​

boolean

true if the strategy was unregistered, false if it wasn't found

Example ​