# Glitch Text — `glitch-text@1.0.0`

A title that glitches like a failing signal: red and cyan channels tear apart, slices jump sideways and a scan line sweeps. Loops perfectly.

A title that glitches like a failing signal. Most of the time it sits steady with a faint red-and-cyan fringe; in short bursts the colour channels tear apart, horizontal slices of the text jump sideways, a scan line sweeps down and the letters flicker. Bursts fall on fixed steps of the loop and every random choice is seeded, so the glitch is identical every time and the last frame is the first. Type the words, choose the colours (rgb, acid, amber or mono), how violent the bursts are, how many steps per loop, the seed and the backdrop colour.

- Kind: text; status: published; digest sha256:e169ddbb5f5e660f25ce4438d394f99218c4b65de431545ad2a941e3b65568f1
- Role: Text scene (Canvas 2D): the cyberpunk, VHS and tech-horror title.
- Implementation: canvas2d; entry `src/glitch-text.js`
- Files: https://aipixelwizard.com/registry/glitch-text/1.0.0/<path> (`LICENSE`, `asset.json`, `demo.js`, `index.html`, `src/glitch-text.js`)
- Manifest JSON: https://aipixelwizard.com/api/v1/visuals/glitch-text/versions/1.0.0
- Runnable demo: https://aipixelwizard.com/registry/glitch-text/1.0.0/index.html (open over http; it imports sibling packages by relative path)
- Dependencies (exact): `apw-runtime@1.0.0` (demo) — Demo harness. The reusable source has no dependencies.

## Exports
- `createGlitchText({ text?, theme?, intensity?, steps?, seed?, maxWidth?, fontFamily? }) => { draw(ctx, info, width, height) }` — Canvas 2D text layer; info.progress (0 to 1 over the loop) sets the step; draws on top of the canvas.
- `THEMES: { rgb, acid, amber, mono }` — Channel colours.

## Parameters
- `text` (text, default "SIGNAL LOST") — Text
- `theme` (select one of rgb | acid | amber | mono, default "rgb") — Colours
- `intensity` (number 0.3–2, default 1) — Intensity
- `steps` (integer 24–120, default 60) — Steps per loop
- `seed` (integer 1–999, default 5) — Seed
- `background` (color, default "#07080c") — Backdrop

## Composition
- Inputs: Canvas 2D context, info.progress (0 to 1 over the loop), width, height.
- Outputs: Draws the text and scan lines on top of the canvas; does not clear it.
- Coordinates: Centred; the line is scaled to 80% of the width; offsets scale with the smaller side of the canvas.
- Lighting: The channels are blended additively, so overlaps brighten like light.
- Timing: Pure function of info.progress; every random value is a hash of the step number.
- Works with: kinetic-title, gradient-background
- Bursts come in runs of one to four steps so that they read as glitches rather than noise.
- Text is treated as private: it is not stored in shared packs unless you choose to include it.

## Output and loop
- 1080×1080, 30 fps, 6 s, procedural
- Seamless loop: yes — Glitch steps are a whole number per loop and each step's burst, slices and flicker come from a seeded hash of the step, so the last frame meets the first.
- Verified 2026-10-08 in Chrome 154.0.8037.97 headless on Linux 7.0.0-38-generic (x64), Node 22.14.0 (Canvas 2D); deterministic: yes; loop check: Frame 0 vs end state (progress 1): mean |Δ| 0.0000, max |Δ| 0 of 255.

## Use it
New project: Create the glitch once, then each frame draw your backdrop and call glitch.draw(ctx, { progress }, width, height).

Existing project: Copy src/glitch-text.js. Call draw on your existing 2D canvas after the rest of the frame.

Reuse ideas:
- Gaming title: Red and cyan.
- Hacker scene: Acid, violent.
- Vintage broadcast: Amber, calm.

## Limitations
- System fonts differ between computers; pass fontFamily and load the font first for identical renders.
- Rapid flicker can be uncomfortable for some viewers; lower the intensity for sensitive audiences.

## License
MIT. Copyright (c) 2026 AI Pixel Wizard. Released under the MIT License. See LICENSE in this folder.

Provenance: Original code written for AI Pixel Wizard in October 2026, to the catalog quality bar (docs/QUALITY.md).

