Web (ttfx-node/web)
The same fx engine as WebAssembly. Packed cells go straight to <canvas> — no terminal emulator, no ANSI parsing. Bundlers pick the browser entry automatically.
import init, { playOnCanvas, listEffects } from 'ttfx-node/web';
await init(); // loads the wasm once
console.log(listEffects().length); // 37
const anim = playOnCanvas(canvas, 'Ship it', 'decrypt', {
seed: 7,
palette: '#daecc6,#bbdd97,#9ece6a,#678549,#39482e',
bands: true,
});
await anim.done;
anim.cancel(); // stop early
Options
- Same vocabulary as Node
play:seed,frameRate, fixedcanvasWidth/canvasHeight palette,background,bands— theme like the CLI flags- Painter opts:
font,cellPx,transparent - Raw engine also exported:
Session(new/step/fill/width/height/free),effect_catalog(),paintFrame()
Notes
- Serve the
wasm/files beside your bundle (see the demo's copy script). - Dynamic-import the entry inside effects so it stays out of SSR bundles.
- Prefer short inputs and bounded effects for ambient loops; cap with
maxFramesthinking.