Tap-origin circular optical theme reveal

I wanted to know if one ElementGL WebGL 2 canvas could run a tap-origin circular theme transition across two live HTML panels, with radial lens magnification and RGB dispersion along the expanding ring while buttons and text fields keep working. Tap any Switch theme from here pill or anywhere on the empty stage, or drag the progress slider to inspect the rim.

Daylight Paper
Samples: 0
Filter: All
Note: Circular lens check
Next: Midnight Studio Origin: (0.84, 0.88)
Midnight Studio
Samples: 0
Filter: All
Note: Circular lens check
Next: Forest Ink Origin: (0.84, 0.88)

Starting...

Show the code two drawable surfaces, tap-origin wavefront controller, optical lens shader, geometry sync and 2D clip
  1. Two full-stage drawable surfaces inside one canvas. #or-surface-a and #or-surface-b each hold corner and centre trigger pills, a counter, filter buttons and an editable <input>.
  2. Deterministic tMs wavefront controller and corner-distance math. Computes maxCornerDist() so the expanding ring reaches the farthest corner at 100%, and steps expansion or collapse from explicit timestamps.
  3. Circular optical mask, radial magnification and RGB dispersion shader. Splits inside and outside textures at r, bends sample coordinates across the ring width, splits red, green and blue channels, and adds a specular glint.
  4. Radial updateElementGeometry() hit sync. Calibrates geometryUnit(), toggles dataset.hitTick, and enables controls inside the circle on Surface B and outside it on Surface A.
  5. Five-argument drawElementImage() 2D radial clip fallback. Clips Surface B inside the expanding circle over Surface A and draws a matching lens rim when WebGL 2 isn't used.

How it works

Both workspaces (#or-surface-a and #or-surface-b) live inside one <canvas content="drawable" layoutsubtree> owned by a single ElementGL WebGL 2 context from /lib/element-gl.js. I set gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true) right after creating the context and again inside onRestored, wait for hasPainted = true inside the paint event, and always call stage.begin() before stage.upload().

When you tap a Switch theme from here pill or anywhere on the empty stage, the script records the normalised coordinate (ox, oy) and computes maxCornerDist(ox, oy) to the farthest canvas corner. At 0%, Surface A is active. At 100%, tapping another trigger promotes the visible theme to Surface A, updates Surface B to the next palette in the cycle (Daylight Paper, Midnight Studio, Forest Ink), waits for the next paint upload so the screen doesn't flash, and expands from 0% at the new tap point.

In ORIGIN_FRAG, pixels inside radius r = progress * maxCornerDist(ox, oy) read from Surface B and pixels outside read from Surface A. Across r ± ringW, a convex dome profile bends texture coordinates radially, offsets red, green and blue lookups along the radial normal for chromatic dispersion, darkens the outer meniscus lip lightly for contrast on bright paper, and adds a specular rim glint. Both .or-surface containers keep pointer-events: none so syncGeometry() can switch inert and pointer-events per control against the current circle radius, while toggling dataset.hitTick clears Chromium's hit-test cache. Playback pauses under IntersectionObserver and document.hidden, falls back to 5-argument drawElementImage() clipping in 2D, and moves both panels into #plain-host if the WebGL context stays lost.

Live checks

Each check builds an isolated fixture on testStage() without touching the demo above. Press Run to test this browser.

Findings