Skip to content

textmode.synth.js / charColor

Function: charColor()

Call Signature

ts
function charColor(source): SynthSource;

Create a synth source with character foreground color defined.

This function creates a SynthSource where the character foreground color is driven by the provided source pattern. This is compositional and can be combined with char() and cellColor().

Accepts either a SynthSource (pattern) or RGBA values (solid color).

Parameters

ParameterTypeDescription
sourceSynthSourceA SynthSource producing color values

Returns

SynthSource

A new SynthSource configured with character color

Example

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

t.layers.base.synth(charColor(osc(10, 0.1, 1.2)).char(noise(8)));

t.windowResized(() => {
	t.resizeCanvas(window.innerWidth, window.innerHeight);
});
codex avatar
@codex{ai-generated}Replace it with your own sketch, claim the credit, and climb the leaderboard.View sketch on GitHub

Call Signature

ts
function charColor(
   r, 
   g?, 
   b?, 
   a?): SynthSource;

Create a synth source with character foreground color defined using RGBA values.

Parameters

ParameterTypeDescription
rSynthParameterValueRed channel (0-1) or value
g?SynthParameterValueGreen channel (0-1) or value
b?SynthParameterValueBlue channel (0-1) or value
a?SynthParameterValueAlpha channel (0-1) or value

Returns

SynthSource

A new SynthSource configured with character color

Example

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

t.layers.base.synth(charColor(1, 0.2, 0.1, 1).char(noise(10)));

t.windowResized(() => {
	t.resizeCanvas(window.innerWidth, window.innerHeight);
});
codex avatar
@codex{ai-generated}Replace it with your own sketch, claim the credit, and climb the leaderboard.View sketch on GitHub

Call Signature

ts
function charColor(gray): SynthSource;

Create a synth source with character foreground color defined using a grayscale value.

Parameters

ParameterTypeDescription
graySynthParameterValueGrayscale value (0-1)

Returns

SynthSource

Example

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

t.layers.base.synth(charColor(0.9).char(noise(6)));

t.windowResized(() => {
	t.resizeCanvas(window.innerWidth, window.innerHeight);
});
codex avatar
@codex{ai-generated}Replace it with your own sketch, claim the credit, and climb the leaderboard.View sketch on GitHub