This document is the behavior contract for the Hilbert Clock. Source of truth
during the TypeScript migration was the former single-file
hilbert/clock.html. The public URL stays
https://nebelmesser.com/hilbert/clock.html.
The clock draws a half-open time interval [start, end) as a 2D space-filling
curve (generalized Hilbert / Gilbert). Consecutive moments stay adjacent on
screen, so an interval appears as a compact region rather than scattered
pixels.
Map colors and most visual constants live as CSS custom properties on :root.
JavaScript reads them (Theme / cssPixel) and does not hard-code the
palette.
Tokens:
--bg — page + surplus behind the map--fg — body text, button labels--muted — captions under the maps--btn-border — idle button + date-input stroke--btn-active — pressed preset fill--btn-active-border — pressed preset stroke--accent — pressed preset label--input-bg — custom date fields--past — elapsed cells not in the live unit--future — cells still ahead--cur-past — elapsed cells inside the live coarsest unit--cur-future — remaining cells inside the live unit--head — the living cell (now)--surplus — leftover cells past the range--label — labels on filled (past) regions--label-empty — labels on empty (future) regions--label-live — live-unit label on the filled half--label-live-empty — live-unit label on the empty half--current-outline — stroke around the live unit--zoom — yellow box + inset frame--zoom-frame-w — square zoom icons + map frames--zoom-muted — disabled zoom icons--connector — diagonals from parent box to inset--bound-0 … --bound-3 — inherited / coarsest / middle / hairline edgesNumeric thresholds (grid score, zoom, labels, fit, loop) are named constants with the values from the original file.
Each panel is four stacked canvases:
ImageData, alpha: false), pixelatedHL_PAD_PX, ZOOM_FRAME_OUTSET)Cells are never stretched: a Fit slot letterboxes to the grid aspect.
For each curve cell with start t0 and duration dur:
now >= t0 + dur → --past, or --cur-past if the cell is in the live
coarsest unitnow inside the cell → --head--future / --cur-future--surplusThe live unit is the coarsest unit on that map. If it covers more than
CURRENT_UNIT_MAX_SHARE (0.9) of the map, drop to the next level (or do not
highlight).
w × h grid.ax, tall slabs along bx.HILBERT_CACHE_MAX = 10).k × k. The refined path stays 4-connected
(8 reflections × 2 directions, pickZoomVariant).pickGrid)Pick w × h and cellDur for the range duration and the available slot
aspect.
ASPECT_MIN 0.42 … ASPECT_MAX 3.2MAX_CELLS = 280000; hard MAX_CELLS_HARD = 1e6 if the parent
must stay 1s-zoomableMIN_CELLS = 16 (except tiny exact ranges)MIN_CELL_PX CSS pixels2³¹ seconds → a 2ⁿ × 2ⁿ square; do not chase the CSS tileD in [1ms, 1s]
(INSET_CELL_DURS: 0.1s, 0.25s, 0.5s, 1s)w×h that tiles the range exactly (no leftover +N)Ladder, coarse → fine. No weeks.
century (roman XXI) → year → month (English names) → day (ordinal 1st) →
hour (HH) → minute (HH:MM) → second (HH:MM:SS) → ms100 → ms10 → ms1
MAX_BOUND_LEVELS (3) local levels, coarsest on top of hairlines--bound-1/2/3 plus hairline clamp (HAIR_MIN … HAIR_MAX)--bound-0 /
INHERIT_WLABEL_DAY_MIN … MAX),
else ~18 regions (LABEL_TARGET_REGIONS)LABEL_PADDING_EM
(0.25 em) of equal clearance on every side before choosing the size,
and LABEL_MAX_PX as the local-label cap (inherited watermarks are uncapped)LABEL_TINY_FRAC × median region area may be omitted;
omit at most LABEL_MAX_OMISSIONS (3), smallest first. Slot shape alone
must never cause a label to be omittedLABEL_LIVE_MS
(10s). For a live unit that is not second, search both filled and empty
parts using the same clearance objective. Keep the entire glyph on one
background; choose its live color from the selected roomspeedup ≠ 1): live / past / empty colors
follow now; placeMask stays the full region; glyph slots are pinned
(_labelPlaces); _liveLabel is not cached--label / --label-empty / --label-live / --label-live-empty
(muted, not translucent)Buttons: D (today), M (month), Y (year), Unix, Range, then + / −.
navStamp)[0, 2147483648000) — signed 32-bit epoch, exactly 2³¹ seconds<input type="date">, inclusive on the inputs; engine range is
[from, to + 1 day). from ≤ today, to ≥ today. Apply after a 1s debouncenowR+ / ↑ / = — smaller window (deeper); − / ↓ / _ — largerZOOM_PARENT_SHARE)D ≤ 1s (INSET_MAX_D); finest 1ms (INSET_MIN_D)cellDur ≤ 1s): default is one panel.
In every preset, − past the coarsest step dismisses the inset
(ZOOM_HIDDEN); + brings the coarsest window backnow is inside the locked box, do not jump to another depth. When it
leaves, slide to the next packed sibling with the same locked duration
(ZOOM_KEEP_AREA_LO / HI) — no spontaneous zoom-in on a mixed 3-way splitZOOM_RES_MAX, ZOOM_CSS_SLACK)+/− keeps the window duration. A real
window resize forgets stored zoom (forgetZoomOnResize)fit-mode)max-height: 540px) shrink chromeformatRange · w×h @ cellDur · +leftoverF, or a double click / double tap on any .map-block, hides the top
bar, the info link, and captions. Maps take the freed spacelocalStoragepointerdown, primary pointer, left button; window
CHROME_DBL_MS = 450, CHROME_DBL_PX = 40; ignore a compatibility mouse
event after touch (< 700ms)touch-action: manipulation on panels — do not zoom the pagefullscreenchange) hides captions and relayouts like FIgnore when Ctrl / Meta / Alt is down, or when focus is in an input.
D M Y U R — presetsF — chrome; Esc leaves F-mode+ = ↑ zoom in; − _ ↓ zoom outlocalStorage key clock-hilbert-frame:
{ mode, layout: "fit", zoom, zoomMs, arbitrary? }
`zoom[mode] === ZOOM_HIDDEN` (−1) means the inset was dismissed.
F-mode is not persisted. Corrupt JSON is ignored.
?time= or ?start= — YYYY-MM-DD-HH:MM:SS or YYYY-MM-DD (local
midnight). The clock keeps ticking from that origin?speedup=X (X > 0) — simulated time is origin + X × wall elapsed,
capped at 1e12. Enables timelapse label rules. Tick period is
finestCellDur / speedup, clamped to 16…1000ms. Invalid values fall back
to 1title is the local instant of that cell
(formatMoment). Surplus / off-map is empty. Touch must not set titlei → /hilbert/G-5D8EGFYM3L; Open Graph / Twitter / canonical as on the live pageorientationchange waits 200ms. A ResizeObserver on the stage does
not drop stored zoom4d/app