Hyperbolic Poincaré disk
I wanted to see if live HTML cards can live inside a non-Euclidean Poincaré disk, bend along circular geodesics under real-time Möbius drag transforms, and stay clickable and focusable through local-Jacobian updateElementGeometry() matrices. Drag the disk to shift hyperbolic space, tap any outer card or press Tab to glide it to the centre, and tick the hit-box overlay to compare the linear tangent box against the curved card edges.
Show the code Möbius isometries, exact inverse GLSL shader, Jacobian hit boxes and geodesic focus glide
- Eight live cards inside one drawable canvas. Each card holds standard HTML controls (inputs, checkboxes, range sliders and buttons) with
drawableset. - Complex Möbius arithmetic and card composition. Combines the view isometry with each card's home translation into one map
M_k(z)and its local derivativeM_k'(0). - Exact inverse Möbius fragment shader. Evaluates
M_k^{-1}(w)per pixel so straight card borders curve into true circular geodesic arcs without mesh faceting. - Local-Jacobian hit boxes. Converts
M_k'(0)into a conformal scale, rotation and translationDOMMatrixforupdateElementGeometry(), and measures the corner curvature error. - Geodesic focus glide. Moves a focused or tapped card along a diameter in hyperbolic distance
atanh(|w|)while unwinding Thomas-Wigner rotation back to upright.
How it works
Everything on the disk runs inside one WebGL 2 context created through new ElementGL(canvas, ...) from /lib/element-gl.js. On each paint event, the eight live cards upload into their textures with gl.texElementSubImage2D(). I then save ElementGL's active program and vertex array object, draw the circular Poincaré disk and its {7, 4} hyperbolic heptagon tiling via iterative circle reflections in GLSL, restore ElementGL's bindings, and draw the eight cards back-to-front.
Card 0 sits at the origin z = 0 and cards 1 to 7 sit at the exact centres of the seven neighbouring heptagons at radius r = 1 / cx (about 0.790). Each card has a home translation H_k(z) = (z + c_k) / (1 + conj(c_k) * z). Dragging from disk point p_0 to p_1 updates the view isometry with T_{-p_1} o T_{p_0} o V_0, so the point under your pointer stays locked to your finger across the whole disk. Composing the view with H_k collapses into one Möbius map M_k(z) = u_k (z - a_k) / (1 - conj(a_k) * z). The fragment shader evaluates M_k^{-1}(w) directly at every pixel, so card edges curve into circular arcs near the horizon instead of showing polygon facets.
canvas.updateElementGeometry() takes a linear DOMMatrix, so it can't bend a hit box into a circular arc. Instead, I linearise M_k at each card's centre using its complex derivative M_k'(0) = u_k (1 - |w_k|^2). That derivative is purely conformal (a uniform scale 1 - |w_k|^2 and rotation arg(u_k) with no shear), which maps directly to a DOMMatrix scaled by geometryUnit() from /lib/surface.js. Whenever a card's transform key changes, I toggle dataset.hitTick so Chromium flushes its hit-test cache without causing an idle paint loop. Turn on "Show hit-box tangent approximation" to see the linear box hug the centred card and diverge at the four corners near the rim.
Pressing Tab moves browser focus into any of the eight cards inside the canvas. A focusin listener starts a geodesic Möbius glide (skipping animation when prefers-reduced-motion: reduce is set) that brings the focused card straight to z = 0 upright, where the conformal scale is 1.0 and the Jacobian hit box matches the rendered card with zero curvature error.
Live checks
These checks build their own fixtures on testStage() and wait for a tap so loading the page never opens extra WebGL contexts or moves focus.
| Status | Check | Result |
|---|
Findings
- Static checks passed on 2026-11-26 (
node --check public/poincare/poincare.js,node tools/gfx/check.mjswith 0 problems, andnode tools/writing/check.mjs /poincare/). Live browser verification in headless Chromium 157 and on Chrome 159 for Android is not verified yet. - Using the exact inverse Möbius transform
M_k^{-1}(w)insideElementGL's fragment shader avoids building a tessellated vertex mesh for each card and keeps curved edges anti-aliased through the analytic derivative|dz/dw|. updateElementGeometry()accepts only a linearDOMMatrix, so curved cards near the Poincaré rim always have corner hit-box error between the curved arc and the tangent rectangle. Gliding a card toz = 0onfocusinor tap collapses that corner error to0.0 pxwhile you type or adjust controls.- Composing pure hyperbolic drags produces real Thomas-Wigner rotation (holonomy) when you drag around a closed loop. Unwinding
arg(u_k)during a geodesic glide brings any card back to upright at the origin. - Gating
card.el.dataset.hitTickon a quantized transform string prevents a DOM mutation on unchanged repaints while still clearing Chromium's hit-test cache whenever a drag or glide moves a card.