Skip to content

textmode.synth.js / char

Function: char()

ts
function char(source): SynthSource;

Create a character source from any color/pattern source.

This function converts any pattern (like osc(), noise(), voronoi()) into character indices. The pattern's luminance or color values are mapped to character indices.

Parameters

ParameterTypeDescription
sourceSynthSourceA SynthSource producing color values that will be mapped to characters

Returns

SynthSource

A new SynthSource configured for character generation

Example

javascript
const t = textmode.create({
  width: window.innerWidth,
  height: window.innerHeight,
  plugins: [SynthPlugin]
});

t.layers.base.synth(
  char(osc(6, 0.1, 1.2))
    .charMap('@#%*+=-:. ')
    .charColor(osc(12, 0.05, 0.2))
);

t.windowResized(() => {
  t.resizeCanvas(window.innerWidth, window.innerHeight);
});