Options

The AsciiOptions object controls every aspect of conversion and rendering. Start from DEFAULT_OPTIONS and override what you need.

ts
import { DEFAULT_OPTIONS, CHARACTER_SETS } from 'asciify-engine';

const options = {
  ...DEFAULT_OPTIONS,
  charset: CHARACTER_SETS.technical.chars,
  fontSize: 8,
  colorMode: 'fullcolor',
};

Core

OptionTypeDefaultDescription
fontSizenumber10Character size in pixels. Controls grid density — smaller = denser grid.
charSpacingnumber1Multiplier applied to cell width and height.
charsetstring' .:-=+*#%@'Character ramp: first char = lightest luminance, last = darkest.
renderMode'ascii' | 'dots''ascii'Render as ASCII characters ('ascii') or filled dot circles ('dots').
invertbooleanfalseInvert luminance mapping — swap light and dark assignment.
customTextstring | undefinedundefinedTile a custom string across all cells instead of the charset ramp.
charsetFramesstring[]undefinedCharset ramps to cycle through over time. Each render picks charsetFrames[floor(time × charsetFps) % length] and remaps cells from their stored luminance.
charsetFpsnumber2Cycle rate for charsetFrames, in frames per second.
ts
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

OptionTypeDefaultDescription
colorMode'grayscale' | 'fullcolor' | 'matrix' | 'accent''grayscale'grayscale = brightness-mapped, fullcolor = source pixel color, matrix = green terminal look, accent = accent color on intensity peaks.
accentColorstring'#d4ff00'Color applied to peak-intensity cells when colorMode is "accent".

Image adjustments

OptionTypeDefaultDescription
brightnessnumber0Brightness offset applied before charset mapping. Range: -1 to 1.
contrastnumber0Contrast adjustment. Range: -1 to 1.
ditherStrengthnumber0Bayer ordered dither intensity. Range: 0 to 1.
dotSizeRationumber0.8Dot circle radius as a fraction of cell size. Dots renderMode only.
charAspectnumber0.55Width ÷ 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.
normalizebooleanfalseAuto-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.

source-crop.ts
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 }
OptionTypeDefaultDescription
top / right / bottom / leftnumber0Insets from each edge. They define the crop window exactly; preserveAspect does not apply.
width / heightnumberfullKeep this fraction of one dimension. With only one given, the other follows it to keep the source proportions.
preserveAspectbooleantrueApplies 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 / ynumbercenteredOrigin 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

OptionTypeDefaultDescription
animationStyleAnimationStyle'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.
animationSpeednumber1Speed 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.

OptionTypeDefaultDescription
hoverEffectHoverEffect'spotlight'The effect near the cursor. Values: 'spotlight' | 'magnify' | 'repel' | 'glow' | 'colorShift' | 'attract' | 'shatter' | 'trail' | 'glitchText'.
hoverStrengthnumber0Hover effect intensity. 0 = disabled. Typical range: 0.3–0.8.
hoverRadiusnumber0.2Hover influence radius in normalized canvas coordinates (0–1).
hoverColorstring'#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.

ts
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.

Trail

A fluid wake changes character density and settles behind your cursor.

Dissolve

Erase a soft path through the characters; the image gradually reforms.

Contour

Fine tonal rings trace your path without moving the grid.

Emboss

Press a light-and-shadow impression into the characters; the grid stays fixed.

Ripple rings

Expanding light-and-shadow rings follow your stroke. Faster movement excites stronger rings; the grid stays still.

Ink bleed

Ink wells up where the cursor rests, spreads along the paper grain, then dries back.

Water

Soft ripples refract the image and settle after your stroke.

Silk

Directional folds follow the movement of your hand.

Vortex

A swirling wake curls through the image.

Magnetic Pull

The image gathers toward your stroke, then relaxes.

Scatter

Characters scatter in soft drifts from your stroke, then spring back into place.

Elastic

Push the image with your stroke; it recoils past its rest once, then settles.

Lens wake

A soft magnifying wake brings details closer, then relaxes back into focus.

Smudge

Drag the image in the direction of your stroke; a smooth, lingering pull settles without a bounce.

Loupe

A glass loupe glides after the cursor and magnifies what it covers, easing through a soft rim.

Reveal

A soft spotlight shows the original photograph through the characters.

Repel

Characters part around the cursor and spring back with one soft rebound when it leaves.

Tilt

The image leans toward the cursor; bright areas sit nearer and move more, like a parallax card.

Heat haze

A rising shimmer bends the characters above the cursor, livelier while you move.

ts
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.

ts
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.