No.122 · Backgrounds
Condensation
A misted window over blurred lights: drops gather, run down the glass and clear a trail that slowly fogs over, and your pointer wipes a streak you can see through.
The prompt
Written for the variant you picked above: City at night
Paint a window in Canvas 2D. Behind it, a scene of out-of-focus lights: a three-stop gradient and soft radial bokeh discs, denser and larger toward the street. Render that scene twice from one base canvas: a lightly blurred 'clear glass' copy and a heavily blurred 'fogged glass' copy with a pale haze and thousands of tiny condensation beads. Blur by drawing small and scaling back up, so it works without canvas filters. A mask canvas records where the glass is clear. Each frame: draw the fogged copy, then the clear copy through the mask (destination-in), then the drops. The mask fades a little every frame (destination-out), so cleared glass mists over again in about nine seconds. Drops appear at random, sit still and gather moisture; once heavy enough they let go and run down with acceleration and a slight sideways wobble, clearing a trail behind them, leaving tiny droplets in it and swallowing the still drops they pass (combining radii). Each drop is a lens: clipped to an ellipse, it shows a wider patch of the clear scene flipped upside down, with a dark rim and a small highlight. Moving the pointer (or dragging on touch) wipes a soft 24px streak. Cap DPR at 1.5, pause offscreen; reduced motion shows a still pane that can still be wiped. Selected variant — City at night: scene="night": a city at night behind the glass — sky gradient #0a0e1d → #1a1530 → #2a1a2a, bokeh lights in amber, coral, warm white and teal (#ffb45c, #ff6a4d, #fff0d2, #5fc8d6, #ffd27a, #ff8f6b) with a city skyline, haze rgba(190,200,222,.16), beads at 22% white. Overlay type in cream.
Notes
- Interaction
- Move the pointer over the glass to wipe it clear; on touch, drag. Cleared glass mists over again.
- Motion
- Drops run with gravity and wobble; trails and wipes re-mist over about 9s. Everything runs on one requestAnimationFrame loop paused offscreen.
- Accessibility
- Decorative canvas (aria-hidden); anything placed on it stays real text. Reduced motion stops the rain and the re-misting; wiping still works because it only moves when you do.
- Responsive
- Regenerates the scene and drops for its size on resize; drop and light counts scale with area.
- On touch
- Drag a finger across the glass to wipe it; vertical page scrolling still works.