Error diffusion revealPro
The classic Mac look as a loading state: Atkinson or Floyd-Steinberg dithers that get finer, computed once in a worker and cached, then resolved into the photo.
On this page
ProAtkinson or Floyd-Steinberg frames at 6, 3 and 2 px, computed in a worker, then the photo.
Installation
Usage
import { ErrorDiffusionReveal } from "@/components/ui/chatcn/pro/error-diffusion-reveal"
<ErrorDiffusionReveal src={image.url} alt={image.prompt} kernel="atkinson" progress={job.progress} />Error diffusion is serial and does not run in a shader, so each step is computed in a worker the moment the image loads, coarse first, and cached by size. If a step is not ready when it is due, the finest ready frame holds instead of a blank.
Examples
States
Waiting for the image, running at 40%, running with no numbers, held by revealed={false}, revealed, a missing file, a timer and right to left.
ProEvery state of the error diffusion reveal.
Props
| Prop | Type | Notes |
|---|---|---|
src, alt | string | alt is required: the accessible name, announced once the image is in |
progress | number | null | Real job progress, 0 to 1. null means running with no numbers. Leave it out for timer mode |
revealed | boolean | Timer mode: false holds the first frame, true plays once the image loads. Default true |
duration | number | Timer length in ms. Default 1800 |
onRevealed | () => void | Once per image, when the plain image shows |
onStatusChange | (status: "loading" | "ready" | "revealing" | "revealed" | "error") => void | |
aspectRatio, width, height | Set the frame before the image loads, so nothing shifts | |
paper | string | The ground under the effect. Token or CSS color. Default var(--chatcn-bg) |
announcement | string | false | What the live region says once revealed. Default Image ready: <alt> |
errorText, retryLabel | Copy for the error state and its reload button | |
kernel | "atkinson" | "floyd-steinberg" | Default atkinson |
steps | number[] | Cell sizes in CSS px, coarse to fine. Default [6, 3, 2] |
ink | string | Default var(--chatcn-fg) |
contrast | number | Default 1.15 |
maxPixels | number | Default 1.5 MP |
Keyboard
| Key | Action |
|---|---|
Tab | Reaches the Reload image button in the error state. The reveal itself takes no focus |
Accessibility
- The effect layer is
aria-hidden. The real<img>with youraltis always there, and the frame isaria-busyuntil the reveal ends. - A polite live region says
Image ready: <alt>once, when the plain image shows. Progress ticks are never announced. - Under
forced-colors: activethe effect hides and the plain image shows with system colors. - A broken file shows what happened and a Reload image button that retries the download.
Motion
- Each step is held for an equal share of 70% of the run; the last 30% crossfades the finest frame into the photo.
- Under reduced motion one still frame holds while the job runs, then the image crossfades in over 200 ms. Nothing moves.
- The timer only runs on screen in a visible tab; offscreen it waits where it was.