The Ulam spiral is made by writing the positive integers in a spiral and marking the primes. Primes fall on certain diagonals far more often than chance allows, revealing striking lines and starbursts. This page renders it as a single infinitely pannable, zoomable canvas.
Every cell of the grid is one integer, laid out ring by ring. Primes glow; zoom in far enough and each cell's number is drawn too. The spiral comes in two forms — the classic square and a hexagonal one — each winding clockwise or anti-clockwise, with every cell drawn as a circle.
| Input | Action |
|---|---|
| Drag (mouse / one finger) | Pan |
| Wheel (mouse) | Zoom at cursor |
| Two-finger scroll (trackpad) | Pan |
| Pinch (trackpad or touchscreen) | Zoom |
| Double-click / double-tap | Zoom in |
| Arrow keys / WASD | Pan |
| + / − | Zoom in / out |
| 0 | Zoom fully out (1 px/cell) and recenter |
| Home | Recenter on n = 1 |
| R | Reset to the initial view |
Numbers up to about 2.7 × 10⁸ are read from a segmented sieve held in the browser as a compact bitset. Beyond that, an exact deterministic Miller–Rabin test decides each cell on demand, so panning near the charted edge (about 10¹²) is as fast as panning just past the surveyed world. Everything runs locally; nothing is uploaded.
A static site built with vanilla TypeScript, Vite and WebGL2 — no runtime dependencies and no tracking.