ASCII backgrounds
A live ASCII background behind any element, in one call. 14 GPU presets through background() from asciify-engine/kit, plus Fluid, the original Asciify hero. Every one takes cursor: false to turn the pointer off.
$ npm install asciify-engineQuick start
Call background() with an element and a preset you import by name. A page pays only for the presets it imports.
import { background, halo, swell } from 'asciify-engine/kit';
const hero = document.querySelector('#hero');
const bg = background(hero, {
preset: halo, // import only the presets you use
clear: hero.querySelector('h1'), // keep the field quiet round your copy
cursor: false, // optional: no pointer response
});
bg.update({ palette: { light: '#5b4bd1', dark: '#8f80ff' } });
bg.setPreset(swell); // cross-fades, keeping your options
bg.destroy(); // on unmountHow it works
- Under your content
One canvas is laid under the element's content (isolation: isolate, z-index: -1), following its border radius. The element keeps its own background colour.
- Drawn on the GPU
Each preset is a scene of the glyph field: one fragment per character cell, so the cost does not grow with pixel density. Every background and kit field on the page draws through one shared WebGL2 context and frame loop. Without WebGL2, supported is false and the element is left as it was.
- Quiet round your copy
Pass clear and the field fades out round that element as the layout changes; without it every preset keeps its own quiet middle.
- Your ink and look
palette (or ink, color) sets the ink per theme and accent the highlights; mark picks characters or dots, charset any ramp, and look takes raw field settings. setGlobalLook() re-skins every background with a charset or one of the 24 render styles; globalLook: false opts one out.
- Pointer and motion
cursor picks the response (trail, fluid, lantern), true keeps the preset's own and false turns it off. Reduced motion holds one still frame; reducedMotion: true or false overrides the visitor's setting.
- Light on the page
A background mounts only near the viewport (lazy, on by default) and pauses off screen and in hidden tabs. GPU memory is budgeted per page: far-off fields give theirs back and show their poster until they return. setFieldBudget(n) caps fields that need a context of their own.
All presets
Backgrounds visitors play with
estuary, capillary and shockwave are simulations rather than scenes: the cursor stirs and lights the smoky currents of Estuary, lights the veins of Capillary so the light runs along them, and brightens Shockwave's wind while a click sends a ring across it. They draw a dark screen of scattered letters whose brightness carries the tone (and every mark and charset) in the theme's ink, start faint enough for a headline, hold a still frame under reduced motion and stop drawing once they settle. A row of pills switching between them with setPreset makes a hero visitors remember.
import { background, capillary, estuary, shockwave } from 'asciify-engine/kit';
const modes = { estuary, capillary, shockwave };
const bg = background(hero, { preset: estuary, clear: headline });
// <div role="radiogroup"><button role="radio" data-mode="estuary">Estuary</button>…</div>
for (const pill of pills) pill.onclick = () => bg.setPreset(modes[pill.dataset.mode as keyof typeof modes]);Cursor trail and page grounds
cursorTrail() lays one click-through layer over the whole page and draws characters along the pointer's path. It mounts on the first pointer move, draws only while something fades, and stays off on touch screens, under reduced motion and in hidden tabs, and quiet over inputs, dialogs and [data-ascii-cursor-skip]. fieldBackground() is the hero's drifting ground in one call (hero, brand or a 404 set large with notFound), with pulse() and scatter().
import { cursorTrail, fieldBackground } from 'asciify-engine/kit';
// Characters that follow the pointer across the whole page
const cursor = cursorTrail({ style: 'trail', ink: '--ink' }); // 'wake' | 'water' | 'sparkle'
// The Asciify hero's drifting ground, clear round the headline
const ground = fieldBackground(document.querySelector('#hero'), {
preset: 'hero', // 'brand' | 'notFound'
clear: document.querySelector('#hero h1'),
});
cursor.destroy();
ground.destroy();Fluid background
From the Asciify hero: flowing ASCII folds and a soft cursor wake, as the fluid preset. Preview it, or download the standalone source.













