Radial clock-face day planner
I wanted to know if live HTML event cards and native <input type="time"> controls can drive a radial 24-hour and 12-hour day planner in WebGL 2, curving each event strip round a polar ring wedge while keeping the active inspector clickable inside the canvas via updateElementGeometry().
Drag the white start or accent end knobs on the dial, edit the event title or times in the bottom dock, or switch between 24h and 12h views.
Selected: Design review (09:00-11:00) ยท drag ring knobs to adjust
Show the code polar shader, inverse-polar handle drag, hit-box sync and 2D fallback
- The dial grip, numeral overlay, event strips and inspector dock inside one canvas. Each event block gets its own
drawablestrip element alongside the flat inspector dock holding<input type="time">controls. - The polar wedge fragment shader. Draws the 24h or 12h dial ticks, wraps each uploaded event texture round a donut sector with automatic bottom-half flip so labels stay upright, and draws start and end knobs on the active block.
- Inverse-polar angle mapping and 15-minute snapping. Converts pointer positions into dial minutes, snaps to 15-minute steps, clamps handle drags against sibling blocks and routes taps inside the dial.
- Syncing
updateElementGeometry()for the flat dock and rotated wedge hotspots. Calibrates CSS scale once per resize viageometryUnit(), bumpsdataset.hitTickand writes inverse hit matrices for the wireframe overlay. - Five-argument
drawElementImage()2D fallback and plain HTML rescue. Draws circular arcs, tangent event badges and the flat inspector when WebGL 2 is absent, or extracts the live controls into plain HTML if the context is lost.
How it works
I rebuilt Isaiah Trotter's Clock Calendar (original post) round live HTML elements inside one <canvas content="drawable" layoutsubtree>.
Each scheduled block has its own drawable .ev-strip element with a real <button>, colour dot, title and formatted time range, while the bottom dock holds a drawable inspector card containing a text input, two native <input type="time"> controls, Prev and Next buttons and a duration <output>.
One ElementGL WebGL 2 context from /lib/element-gl.js uploads the changed elements inside the paint handler via gl.texElementSubImage2D() only after the first paint has fired.
Pass 0 renders the clock bezel, quarter-hour ticks, day-night inner band and the live HTML numeral overlay.
Pass 1 draws one full-canvas quad per event strip, evaluating a rounded donut-wedge distance field and warping the strip texture radially and tangentially along the arc (flipping the UVs on the lower half of the clock so labels still read left to right).
Pass 2 adds the live current-time needle and any hit-test wireframes, and Pass 3 composites the interactive inspector dock 1:1 at the bottom of the canvas.
Because a polar curve can't be represented by one affine DOMMatrix, dragging the start or end knobs runs inverse-polar pointer maths on the CPU (atan2(dx, -dy) with unwrapped angular accumulation), snaps to 15-minute increments, clamps against neighbouring events so blocks don't overlap during drags, and writes the updated HH:MM values straight back into #ev-start and #ev-end.
For tapping and keyboard navigation, syncClockGeometry() computes a rotated tangent DOMMatrix at each wedge's midpoint plus the flat dock translation, scales both by geometryUnit(), calls canvas.updateElementGeometry() and toggles dataset.hitTick.
A circular #clock-dial-grip element with touch-action: none covers the dial face so finger drags don't pan the page, while the sweep loop pauses automatically off screen via IntersectionObserver and stops under prefers-reduced-motion: reduce.
Live checks
These checks wait for a tap so the page opens with one WebGL context. Each check builds its own isolated fixture on the test stage and retires its canvas afterwards.
Findings
- Not verified in a live browser yet: none of the live checks, polar wedge uploads, handle drags or
elementsFromPoint()hit probes have been measured in headless Chromium 157 or Chrome 159 on Android yet. Run the checks above to record results on this device. - Sampling each event strip in its own
ElementGLpass keeps the shader texture count at one sampler (uTex) regardless of how many blocks are added, avoiding uniform sampler arrays and letting each block carry its own active glow and knobs. - In 12-hour mode, morning and afternoon events that share a clock sector (such as 09:00 and 21:00) collide if drawn in one track, so
computeLanes()splits colliding intervals into inner AM and outer PM concentric bands while leaving non-overlapping blocks across the full track width. - HTML
<input type="time">rejects24:00, so 24-hour end drags clamp at23:59after passing the23:45snap mark so the native time field stays valid.