Options
The AsciiOptions object controls every aspect of conversion and rendering. Start from DEFAULT_OPTIONS and override what you need.
import { DEFAULT_OPTIONS, CHARACTER_SETS } from 'asciify-engine';
const options = {
...DEFAULT_OPTIONS,
charset: CHARACTER_SETS.technical.chars,
fontSize: 8,
colorMode: 'fullcolor',
};Core
| Option | Type | Default | Description |
|---|---|---|---|
fontSize | number | 10 | Character size in pixels. Controls grid density — smaller = denser grid. |
charSpacing | number | 1 | Multiplier applied to cell width and height. |
charset | string | ' .:-=+*#%@' | Character ramp: first char = lightest luminance, last = darkest. |
renderMode | 'ascii' | 'dots' | 'ascii' | Render as ASCII characters ('ascii') or filled dot circles ('dots'). |
invert | boolean | false | Invert luminance mapping — swap light and dark assignment. |
customText | string | undefined | undefined | Tile a custom string across all cells instead of the charset ramp. |
charsetFrames | string[] | undefined | Charset ramps to cycle through over time. Each render picks charsetFrames[floor(time × charsetFps) % length] and remaps cells from their stored luminance. |
charsetFps | number | 2 | Cycle rate for charsetFrames, in frames per second. |
import { asciify, CHARACTER_SETS } from 'asciify-engine';
await asciify(img, canvas, {
options: {
charsetFrames: [CHARACTER_SETS.standard.chars, CHARACTER_SETS.blocks.chars],
charsetFps: 2,
},
});
// charsetFrames keeps a still animating; leave it unset for a static image.Color
| Option | Type | Default | Description |
|---|---|---|---|
colorMode | 'grayscale' | 'fullcolor' | 'matrix' | 'accent' | 'grayscale' | grayscale = brightness-mapped, fullcolor = source pixel color, matrix = green terminal look, accent = accent color on intensity peaks. |
accentColor | string | '#d4ff00' | Color applied to peak-intensity cells when colorMode is "accent". |
Image adjustments
| Option | Type | Default | Description |
|---|---|---|---|
brightness | number | 0 | Brightness offset applied before charset mapping. Range: -1 to 1. |
contrast | number | 0 | Contrast adjustment. Range: -1 to 1. |
ditherStrength | number | 0 | Bayer ordered dither intensity. Range: 0 to 1. |
dotSizeRatio | number | 0.8 | Dot circle radius as a fraction of cell size. Dots renderMode only. |
charAspect | number | 0.55 | Width ÷ height of a single output character. Must match your rendering env: 0.5 for most terminals, 0.52 for browser line-height 1.15, 0.55 for line-height 1.09. Controls how many rows vs cols are generated so output has correct proportions. |
normalize | boolean | false | Auto-stretch the luminance range of the frame before charset mapping. Maximises detail for low-contrast or muted images. |
Source crop
sourceCrop removes empty source edges before sampling, on any source. Use CSS-like insets as fractions of the source: each side cuts that much from its edge. asciifyVideo sizes its canvas from the cropped aspect, so a top and bottom crop becomes a wide band without stretching.
await asciifyVideo('/hero.mp4', canvas, {
fitTo: '#hero',
options: {
sourceCrop: { top: 0.08, bottom: 0.22 },
},
});
// Sides, or any combination:
sourceCrop: { left: 0.1, right: 0.1 }
sourceCrop: { top: 0.08, right: 0.12, bottom: 0.22, left: 0.12 }
// One dimension: keep the middle 70% of the height, proportions preserved.
sourceCrop: { height: 0.7 }
sourceCrop: { height: 0.7, anchor: 'top' }
// An exact window that ignores the source proportions:
sourceCrop: { x: 0.05, y: 0.08, width: 0.9, height: 0.9, preserveAspect: false }| Option | Type | Default | Description |
|---|---|---|---|
top / right / bottom / left | number | 0 | Insets from each edge. They define the crop window exactly; preserveAspect does not apply. |
width / height | number | full | Keep this fraction of one dimension. With only one given, the other follows it to keep the source proportions. |
preserveAspect | boolean | true | Applies only to single-dimension width or height crops. false keeps the exact window you give. |
anchor | 'center' | 'top' | 'bottom' | 'left' | 'right' | corners | 'center' | Where an auto-centered crop sits, e.g. 'bottom' or 'top-left'. |
x / y | number | centered | Origin of an exact width/height window. |
unit | 'percent' | 'pixel' | 'percent' | Read values as 0–1 fractions or as source pixels. |
Crop reframes the media; objectFit, objectPosition and bleed place the rendered canvas in your layout. With chromaKey on as well, video also trims the keyed background inside the crop: see keyed auto-trim.
Built-in engine animation
| Option | Type | Default | Description |
|---|---|---|---|
animationStyle | AnimationStyle | 'none' | Still-image motion, read from the image's own light and depth: 'none' | 'relight' | 'sheen' | 'glow' | 'shimmer' | 'parallax' | 'push' | 'focus' | 'mist' | 'current' | 'develop'. Retired IDs (caustics, grain, trace, tidal, weave, breeze, reform, print, unfold) load as their closest replacement. Hover and optical finishes remain separate. |
animationSpeed | number | 1 | Speed multiplier for all animation effects. |
Built-in engine hover
These IDs belong to the published npm package. For the current playground and hero interactions, use the optional studio surface below. For example, Water is a studio module effect, not a valid npm hoverEffect value.
| Option | Type | Default | Description |
|---|---|---|---|
hoverEffect | HoverEffect | 'spotlight' | The effect near the cursor. Values: 'spotlight' | 'magnify' | 'repel' | 'glow' | 'colorShift' | 'attract' | 'shatter' | 'trail' | 'glitchText'. |
hoverStrength | number | 0 | Hover effect intensity. 0 = disabled. Typical range: 0.3–0.8. |
hoverRadius | number | 0.2 | Hover influence radius in normalized canvas coordinates (0–1). |
hoverColor | string | '#ffffff' | Secondary color used by colorShift and glow effects. |
Living images in the playground
Still-image motion reads the photo’s own light, depth, water and sky: Relight, Specular sweep, Highlight bloom, Glints, Parallax, Slow push, Focus pull, Mist, Drift and Develop. Light motions keep the character grid anchored; Parallax, Slow push and Drift move the image through it. The same identifiers work in the core animationStyle, the hover module’s motion, and Studio’s motion.type, and retired ids (caustics, tidal, reform…) load as their closest replacement. Choose one motion owner; leave source video alone by default. Pause and reduced motion stop automatic movement.
import { mountHover } from 'asciify-engine/hover';
const surface = mountHover(host, canvas, {
motion: 'relight', // 'sheen' | 'glow' | 'shimmer' | 'parallax' | 'push' | 'focus' | 'mist' | 'current' | 'develop' | 'none'
motionSpeed: 1, effect: 'trail', strength: 0.55,
fineDither: false, fontSize: 7
});
// Keep engine animationStyle: 'none' and hoverStrength: 0.
// Set animated: true only when the source canvas itself updates.
// Call surface.destroy() on unmount.Studio surface hovers
The hero and playground share 19 hovers, including Lens wake, Smudge and Ripple rings in 4.10.0. Lens wake magnifies a local area; Smudge follows your stroke without a bounce; Ripple rings expands light and shadow without moving the grid. Use STUDIO_HOVERS and STUDIO_MOTIONS for the full catalogs, and STUDIO_ANIMATION_PRESETS for six editable pairings. Import mountHover from asciify-engine/hover (1.2.0+) to use these effects. They are included in npm; no extra download is needed. Root and core imports do not load the optional surface renderer. The engine’s original hover effects remain available separately.
A fluid wake changes character density and settles behind your cursor.
Erase a soft path through the characters; the image gradually reforms.
Fine tonal rings trace your path without moving the grid.
Press a light-and-shadow impression into the characters; the grid stays fixed.
Expanding light-and-shadow rings follow your stroke. Faster movement excites stronger rings; the grid stays still.
Ink wells up where the cursor rests, spreads along the paper grain, then dries back.
Soft ripples refract the image and settle after your stroke.
Directional folds follow the movement of your hand.
A swirling wake curls through the image.
The image gathers toward your stroke, then relaxes.
Characters scatter in soft drifts from your stroke, then spring back into place.
Push the image with your stroke; it recoils past its rest once, then settles.
A soft magnifying wake brings details closer, then relaxes back into focus.
Drag the image in the direction of your stroke; a smooth, lingering pull settles without a bounce.
A glass loupe glides after the cursor and magnifies what it covers, easing through a soft rim.
A soft spotlight shows the original photograph through the characters.
Characters part around the cursor and spring back with one soft rebound when it leaves.
The image leans toward the cursor; bright areas sit nearer and move more, like a parallax card.
A rising shimmer bends the characters above the cursor, livelier while you move.
import { asciify } from 'asciify-engine';
import { mountHover } from 'asciify-engine/hover';
// A positioned wrapper fitted to the canvas:
// <div id="art" style="position:relative;width:fit-content">
// <canvas id="ascii"></canvas>
// </div>
const host = document.querySelector<HTMLElement>('#art')!;
const canvas = document.querySelector<HTMLCanvasElement>('#ascii')!;
const charset = ' .:-=+*#%@';
const stop = await asciify('/image.jpg', canvas, {
fontSize: 7, options: { charset, charAspect: 0.58, hoverStrength: 0, animationStyle: 'none' }
});
const hover = mountHover(host, canvas, {
effect: 'trail', // 'water' | 'contour' | 'dissolve' | 'silk' | 'vortex' | 'magnetic' | 'scatter' | 'none'
strength: 0.55, radius: 0.2, fontSize: 7, charAspect: 0.58, charset
});
// Match custom artwork: charset, customText, renderMode, dotSizeRatio
// For video/GIF: animated: true, fps: 30
// After redrawing a still: hover.invalidate()
// On unmount: hover.destroy(); stop();Download the standalone hover module for a project without a bundler. Save it locally and import mountHover from that file.
Use your own letters
Change charset to incorporate brand letters while keeping light and dense symbols. customText repeats a phrase and is a different option. The HTML headline is also separate from the artwork’s character set.
const letters = [...new Set('ASCIIFY'.toUpperCase().replace(/[^A-Z]/g, ''))].join('');
const charset = ' .:-=+' + letters + '#%@';
await asciify('/image.jpg', canvas, {
fontSize: 7,
options: { charset, colorMode: 'fullcolor', hoverStrength: 0 },
});Layer the headline through the artwork or tune rendering performance.