Drift is a single-file, no-dependency HTML canvas toy. Touch or drag anywhere on the screen to paint with particles, stars, portals, or rain — no install, no build step, just open index.html in a browser.
- Download
index.html. - Open it directly in any modern browser (Chrome, Safari, Firefox, Edge).
- Drag your mouse or finger across the canvas to begin.
No server, bundler, or dependencies required — everything (HTML, CSS, and JS) lives in one file.
The bottom control panel lets you switch between seven drawing modes:
| Mode | Behavior |
|---|---|
| Ink | Soft, dark, flowing trails with light drag and gravity. |
| Fire | Warm, buoyant embers that rise and fade (additive blending). |
| Neon | Bright, glowing streaks with no gravity — pure color trails. |
| Water | Heavier, slower droplets that fall and pool. |
| Universe | Drag to sprinkle stars across a nebula backdrop; hold (without moving) to place a gravity well that pulls nearby stars in. Shooting stars appear periodically. |
| Portal | Tap to open a swirling portal. Choose a portal "flavor" (Space, Fire, Ocean, Cyber, Magic) from the flavor picker that appears above the panel. |
| Rain | Drag to wipe condensation off a foggy glass surface, revealing drips and splashes underneath. |
- Draw: click-and-drag (mouse) or touch-and-drag (mobile/tablet), works with pointer events so it supports mouse, touch, and stylus input.
- Save image (down-arrow icon): exports the current canvas as a PNG (
drift-<timestamp>.png). - Clear canvas (trash icon): wipes all particles, stars, portals, and rain, and resets the background for the current mode.
- Rendering: a single
<canvas>element with a 2D context, redrawn every frame viarequestAnimationFrame. - Particle system: each drawing mode (
ink,fire,neon,water) is defined by a palette object inPALETTES— controlling hue range, saturation, lightness, gravity, drag, lifespan, spread, and blend mode (source-overvslighter/additive). - Trail effect: instead of clearing the canvas each frame, a semi-transparent rectangle is painted over the whole canvas, letting old particles fade out gradually.
- Universe mode: a separate particle system (
uniStars) layered over a parallax starfield and drifting nebula clouds, plus gravity wells (uniWells) that attract nearby stars, and randomly spawned shooting stars. - Portal mode: swirling particle rings (
portalBits) emitted from up to 3 active portals, each with its own color palette fromPORTAL_TYPES. - Rain mode: a fogged-glass simulation where dragging "wipes" a clear path, and physics-driven raindrops trickle and occasionally splash.
- Responsive canvas: automatically resizes to the window and accounts for device pixel ratio (capped at 2x) for crisp rendering on high-DPI screens.
Requires a browser with support for the Canvas 2D API and Pointer Events (all modern desktop and mobile browsers). No external libraries or network requests are used.
index.html — everything: markup, styles, and script in one file
README.md — this file
- Add new palettes to
PALETTESfor additional drawing modes. - Add new portal flavors to
PORTAL_TYPES. - Tweak
MAX_PARTICLES,MAX_STARS, orMAX_PORTAL_BITSto trade visual density for performance. - Adjust
gravity,drag, andlifevalues per palette to change how particles move and fade.