Skip to content

textmode.synth.js / SynthSource

Class: SynthSource

A chainable synthesis source that accumulates transforms to be compiled into a shader.

This is the core class that enables hydra-like method chaining for generating procedural textmode visuals. Each method call adds a transform to the chain, which is later compiled into a GLSL shader.

Example

Chain utilities

Methods for reusing or copying an existing synthesis chain.

MethodDescription
cloneCreate a deep clone of this SynthSource. Useful when you want to create a modified version of an existing chain without affecting the original.
transformApply a registered transform by name with explicit arguments.

Color transforms

Methods that adjust, extract, or remap the colors produced by a source.

MethodDescription
bExtract the blue channel as a grayscale value.
brightnessAdjust brightness.
clampClamp color values to a specified range for stability.
colorMultiply all channels by a scalar value (grayscale).
coloramaApply colorama effect (hue rotation based on luminance).
contrastAdjust contrast.
gExtract the green channel as a grayscale value.
gammaApply gamma correction for nonlinear brightness control.
hueShift hue.
invertInvert colors.
levelsAdjust input/output levels and gamma for precise tonal control.
lumaApply threshold based on luminance.
posterizePosterize colors to limited palette.
rExtract the red channel as a grayscale value.
saturateAdjust color saturation.
shiftShift color channels by adding offset values.
threshApply hard threshold.

Combining sources

Methods that blend, mask, or layer one synth source with another.

MethodDescription
addAdd another source.
blendBlend with another source.
burnColor burn blend with another source.
darkenDarken blend with another source.
diffDifference with another source.
dodgeColor dodge blend with another source.
hardlightHard light blend with another source.
layerLayer another source on top.
lightenLighten blend with another source.
maskMask using another source.
multMultiply with another source.
overlayOverlay blend with another source.
screenScreen blend with another source.
softlightSoft light blend with another source.
subSubtract another source.

Coordinate modulation

Methods that use one source to distort another source's coordinates.

MethodDescription
modulateModulate coordinates using another source.
modulateHueModulate coordinates based on hue differences.
modulateKaleidModulate kaleidoscope using another source.
modulatePixelateModulate pixelation using another source.
modulateRepeatModulate repeat pattern with another source.
modulateRepeatXModulate X repeat with another source.
modulateRepeatYModulate Y repeat with another source.
modulateRotateModulate rotation using another source.
modulateScaleModulate scale using another source.
modulateScrollXModulate X scroll using another source.
modulateScrollYModulate Y scroll using another source.

Coordinate transforms

Methods that reshape the sampling coordinates before a source is evaluated.

MethodDescription
barrelBarrel distortion (bulge outward).
fisheyeFisheye lens distortion.
kaleidApply kaleidoscope effect.
mirrorMirror coordinates across X and/or Y axes.
pinchPinch distortion (pull inward).
pixelatePixelate the output.
polarConvert coordinates to polar space.
repeatRepeat coordinates in both X and Y directions.
repeatXRepeat coordinates in X direction.
repeatYRepeat coordinates in Y direction.
rotateRotate coordinates.
scaleScale coordinates.
scrollScroll coordinates in both X and Y directions.
scrollXScroll coordinates in X direction.
scrollYScroll coordinates in Y direction.
shearShear coordinates along X and Y axes.
swirlSwirl distortion around a center.
twirlTwirl distortion with radial falloff.

Determinism

Methods that make noise-based source chains reproducible.

MethodDescription
seedSet a seed for deterministic randomness in this source chain.

Output Channels

Methods that choose characters and route values to character and cell colors.

MethodDescription
cellColorSet the cell background colors using a color source chain.
charSet the character indices using a character source chain. The number of characters is determined by charMap() if defined, otherwise falls back to the total characters in the layer's font.
charColorSet the character foreground color using a color source chain.
charMapMap character indices to a specific character set. This is the primary textmode-native way to define which characters to use.
paintSet both character foreground and cell background color using the same source chain. This is a convenience method that combines .charColor() and .cellColor() in one call.

Sources & Sampling

Methods that begin a chain from procedural patterns, feedback, or a sampled source.

MethodDescription
gradientGenerate a rotating radial gradient.
moireGenerate moire interference patterns.
noiseGenerate Perlin noise patterns.
oscGenerate oscillating patterns using sine waves.
plasmaGenerate plasma-like sine field patterns.
shapeGenerate geometric shapes (polygons).
solidGenerate a solid grayscale color.
srcSample the previous frame for feedback effects.
voronoiGenerate voronoi patterns.