The fade that ate the canvas
August 21, 2026 · 1 min read
A trail effect on a 2D canvas is usually written as a translucent rectangle painted over last frame. The alpha is the persistence, and it is almost always derived from a slider.
The bug arrives when the slider’s range and the alpha’s domain are decided by different people, or by the same person on different days. Ours read 1 - trailLength * 0.15, with the slider ranged from -2 to 16. Somewhere around 6.7 the alpha reaches zero and the canvas stops clearing. Past that it goes negative, the browser ignores the fill, and the picture becomes an accumulating smear that never resolves.
Nothing errors. Nothing warns. Half the slider’s travel is a broken picture that looks, at a glance, like an artistic choice.
The fix is not a bigger clamp on the slider. It is to make the parameter a fraction of something — a persistence between nothing and almost-everything — so the arithmetic that turns it into an alpha cannot leave the valid range no matter what arrives.