A text field that burns away when you send it
I wanted to know if a live text field inside a canvas could be sent and burnt off in place: the letters you typed lift away as embers while the field underneath is already empty and ready for the next line. Type something and press Send, or watch the demo lines go.
After Vanish Input by Rauno Freiberg (in Elsewhere).
Show the code the markup, the copy, the embers, the send, the card size
- The markup. A
<form>with a text field, a submit button and a list of sent chips, as the one drawable child of a 2D canvas. - Styles. The field has one flat colour inside its border, so its text box holds only background and glyphs.
- The copy. The text box is copied once with
drawImage()into a plain canvas, and only that copy is read. - The embers. Each dark texel becomes an ember, let go from left to right, lifted and pushed by a wavering wind, in fixed steps from a seeded generator.
- The send. In the paint after a submit: copy, spawn, paint the field colour over the old text for that frame, clear the live field and add a chip.
- The card size. The form gets the canvas size in pixels from script, so its hit boxes match where it is drawn.
How it works
The form is an ordinary <form> with a text field, a Send button and a list of sent messages. It's the one drawable child of a 2D canvas, drawn at the canvas size with drawElementImage(form, 0, 0, width, height) in every paint. So the field takes focus, typing, selection and Enter like any other field, and Send is a real submit button.
One copy. On submit the page asks for a paint. In that paint, after the form is drawn, the text box of the field (inside its border) is copied out of the canvas twice with drawImage(): once at device scale into a small canvas that keeps the letters, and once at twice CSS scale into a plain canvas made with willReadFrequently. That plain canvas is the only thing read with getImageData(), once per send. The drawable canvas is never read and never made with willReadFrequently.
Embers. Every texel of the copy darker than 120 is a glyph texel. Up to 2,600 of them become embers. A cut runs across the text from left to right in 0.55 seconds: to its right the kept letters are drawn as they were, and to its left each ember is let go, flashes white, cools through orange and red, rises and drifts on a wavering wind. The simulation runs in fixed steps of 1/60 s from a generator seeded by the text, so the same line gives the same plume.
A clean field. In the same paint the field's colour is painted over its old text, the live field's value is set to an empty string and a chip with the text is added to the list. The next paint draws the form with the empty field, so the letters are only ever in the embers.
Before you type. The page sends its first line on the first paint, drawn 0.9 seconds in, and then fills and sends a demo line every few seconds until you touch the form or untick the box. With reduced motion on, each plume is drawn once, 1.3 seconds in, as a still frame, and the demo lines wait.
Live checks
These run on their own copies of the form, on small canvases in the corner of the window. They don't touch the demo above.
Findings
- Measured in Chrome Canary
161.0.8200.0on 2026-12-04 at 412 by 915 CSS pixels, device scale 2.625, software rendering (SwiftShader): all 8 live checks pass, with no script errors, no lost canvases, no wrong-size draws and no horizontal overflow. The demo canvas is 998 by 1,050 (1.05 MP, 4.4 MB on load). - One copy is enough. The text box of a field holding "vanish me" copied into a 406 by 84 plain canvas gave 1,327 texels darker than 120, and the empty field gave 0. Sending "bring the blue umbrella" turned 3,128 texels into 2,613 embers.
- The live field is clean straight after a send. Its value was an empty string, the chip list grew by one, and a copy of the field taken in the next paint, before the embers were drawn, had 0 dark texels.
- The drawable canvas is never read. Over a send the guard counted 0
getImageData()calls on drawable canvases and 1 read of the plain copy, 0 drawable canvases made withwillReadFrequently, and 0 unasked GPU readbacks on the page. - The form is hit where it's drawn. The card is as tall as the canvas (330 of 330 px on the fixture, 400 of 400 px on the demo),
elementsFromPoint()found the Send button at its centre and 1 px above its bottom edge, the form 4 px below it, and the field where it's drawn, on a fixture and on the demo's own Send button: 0 px vertical offset. - With reduced motion two fresh copies sending the same line gave the same frame, hash
a903bcfcboth times, 1,665 embers and 47,446 warm pixels, frozen 1.3 seconds in. - Drawing 2,600 embers took 0.34 ms a frame at scale 2.625 in the test browser. Not verified on a phone.
- In the test browser
devicePixelContentBoxSizereported 380 by 400 under device emulation, so the canvas first came out at scale 1 and the field was blurred. A second resize observer sets the size fromdevicePixelRatiowhen the two differ by more than a pixel. - Letters let go one ember at a time looked dotted when a long line had more dark texels than the 2,600 embers allowed. The text that hasn't burnt yet is now drawn from a crop of the field behind a cut that moves left to right, and embers start only behind the cut.