Skip to content
motionprompts motionprompts

ASCII Image Reveal Effect

JavaScript animation component · Published 2026-07-21 · Updated 2026-08-16 · by vanguardia.dev

Open live demo ↗ Download source

What it does

Editorial photo grid where each frame paints itself as live ASCII on a canvas as it scrolls into view: cells pop in in random order, the lit mid-tones flicker through dense glyphs before locking, and the settled ASCII holds a beat before cross-fading to the real photograph. The glyph grid is measured from the tile's own box, so it stays legible from a 250px desktop frame down to a 170px phone tile; tapping a frame scans it again.

How it's built

Categorygallery
Techvanilla JS
Complexitysection
Performance costmedium
Mobile-safeyes

ascii canvas reveal scroll scramble grid gallery vanilla-js

How it works

An editorial photo grid where every frame develops in front of you. When a frame scrolls into view it first appears as ASCII art: characters pop in across the tile in random order, the shadows snap straight to their final glyph, and the lit parts of the picture, usually the face, flicker through dense random characters for a moment before they lock. Once the whole picture has formed in text, it holds for a beat and then dissolves into the real photograph. Frames that enter together cascade one after another, and tapping or clicking a frame scans it again.

There is no library behind it, not even GSAP. It is the Canvas 2D API, one small animation loop per tile and an IntersectionObserver.

Turning a photo into characters

Each image is cropped to its tile, shrunk down to one pixel per character cell, and read back pixel by pixel. Every cell's brightness picks a character from a ramp that goes from empty to dense. Because the canvas draws light glyphs on a dark ground, more ink means more light, so bright areas must get the dense characters.

A short ramp is a coarse instrument, and a set of photographs never shares one exposure. So every frame is levelled on its own before it is mapped: the ends of its brightness range are stretched across the ramp, and very bright, high-key images are pulled down so their midtones land in the middle of the ramp instead of piling up as solid blocks.

The grid is measured, never assumed. The number of columns comes from the tile's real width, the font size from the measured width of one character of the monospace face, and the canvas is sized to the tile's actual pixels.

The flicker and the trigger

The animation is a small state machine per cell. Cells come in at a steady rate in shuffled order; dark ones settle at once, brighter ones flip through random dense glyphs a few times before showing their real character. That split is why the face resolves last.

The scan starts when a tile enters the viewport, never on page load, otherwise most frames would finish before anyone scrolls to them.

Robustness, performance and mobile

Much of the craft is in failing well. With JavaScript off the page is a normal photo gallery. A photo that fails to load, a cross-origin image that cannot be read, or an observer that never fires all fall back to the photograph instead of leaving a dark box. Tiles waiting below the fold show a faint scatter of glyphs rather than a black rectangle. The scan waits for the web font, because measuring the fallback font would build every grid to the wrong size, and it rebuilds on resize and rotation. Reduced motion paints the finished ASCII without the flicker. On phones the grid drops to fewer columns so each tile stays wide enough to hold a likeness.

Rebuild it with AI

This component's prompt is part of the paid library. Below you can read how it starts; the full prompt, the exact structure, timing and easing an AI agent needs to rebuild the effect, unlocks with any paid plan, yearly or lifetime.

# ASCII Image Reveal Effect
## Goal
Build an editorial photo grid where **each frame paints itself as live ASCII art on a `<canvas>` the moment it scrolls into view**, then cross-fades into the real photograph. Cells fill in **random order**; the shadow cells snap straight to their final glyph while the mid-tones and highlights — the lit part of the face — **flicker through dense random glyphs** for about three quarters of a second before locking in. When a whole grid has settled it holds for a beat, then dissolves to the photo. Frames that enter together cascade 140 ms apart. Tapping or clicking a frame scans it again.
## Tech
Vanilla HTML/CSS/JS. **No GSAP, no libraries, no framework, no npm dependencies** — the whole effect is hand-rolled with the **Canvas 2D API**, one `requestAnimationFrame` loop per tile, and an `IntersectionObserver`. A single ES-module script (`<script type="module" src="./script.js">`) drives everything.
## Layout / HTML
A single `<section class="gallery">` holding an `.intro` block and **15** `<figure class="frame fN">` elements. Each figure holds a `<div class="img">` wrapper with one `<img class="ascii-reveal">` inside it, plus a `<figcaption>`. The script inserts a `<canvas>` into each `.img` at runtime.
```html
<section class="gallery">
  <div class="intro">…eyebrow, h1, lede, credits, hint…</div>
  <figure class="frame f1">
    <div class="img">
…

Premium prompt

Unlock this prompt, and every other one

From $99/year, or $139 once for lifetime access. Commercial license included.

See pricing Or start with the free set Already bought? Sign in

New components in your inbox

One email a week, only when new components ship, each with its live demo and prompt.