Selected letters as particles

Select some of the text. When the selection stops changing, its letters come loose and fall to the bottom of the article. “Swirl” moves them in rings and “Put them back” returns each one to its place. The text in the DOM doesn't change at any point.

Loose type

A page of metal type was a few thousand separate pieces held in a frame by pressure. If the frame was dropped, the letters fell out and had to be sorted by hand before anything could be printed again.

Text on a screen has no pieces. A selection can still be measured one character at a time, and a canvas that draws the text can leave any character out and draw it somewhere else.

Select a word, a line or the whole article.

No loose letters.
Show the code letter rectangles, the hole and the two ways to draw a letter
  1. The article inside <selection-fx> with the effect named glyphs.
  2. One rectangle per character, from a Range around each one.
  3. Let go: take a snapshot of the canvas and make a particle for each rectangle.
  4. Leave the letters out of the text with an even-odd clip.
  5. Draw one letter, from the snapshot or from the element through a clip.
  6. Fall, swirl and return.

How it works

A Range around a single character has one client rectangle. The page collects those rectangles for the selection and gives each one a particle. On every frame the canvas draws the article through a clip path that leaves out the home rectangle of every loose letter, then draws each letter at its particle's position and angle. A letter comes from one of two places. The snapshot is a copy of the canvas taken at the moment the letters are let go, and each letter is a drawImage() of a small part of it. The live route calls drawElementImage() once per letter with a clip the size of the letter, so a letter in the air still follows changes to the element (hover, a new colour, an edit).

Live checks

These start when you press the button. They use their own fixture.

Findings

Measured in headless Chromium 157 on Linux with a software renderer, 2026-11-21.

Not verified: frame rate on a phone with several hundred letters, and the automatic drop after a touch selection made with the Android handles (the page waits 0.7 s after the last change).