Radial pie menu with wedge warp

I wanted to know if one ElementGL WebGL 2 canvas could draw a Blender-style radial pie menu of live HTML <button> items over an interactive workspace card, complete with a frosted glass ring, directional selection beam, spring wedge stretch and accurate clicks at any tap point. Tap a wedge directly, drag-flick from anywhere on the canvas, or tap empty canvas space to move the menu.

Viewport target 0° · 1.00× · Dark

Transform target

Accent · Coral

Angle0°
Scale1.00×
GridOff
Ready · tap wedge or drag Tap stage to move ring

Starting...

Show the code drawable workspace and radial ring, spring detent, WebGL 2 wedge warp, geometry sync and 2D fallback
  1. Two drawable children inside one canvas. #pm-workspace holds the target card that transforms under commands, while #pm-ring holds six real <button> items spaced at 60° intervals.
  2. Damped spring detent and opening bounce. Drives menu scale, per-wedge radial pull and wedge scale with explicit timestamps so live checks can step the simulation deterministically.
  3. Glass ring backdrop, selection beam and barrel bulge shader. Pass 0 refracts the workspace under a frosted annulus and draws the directional beam; Pass 1 adds a centre-anchored barrel bulge and specular border glow to the active wedge.
  4. Hit-box calibration with updateElementGeometry(). Positions #pm-ring at the tap coordinate with geometryUnit() and flips dataset.hitTick so moved and pulled buttons register clicks.
  5. Five-argument drawElementImage() 2D fallback. Draws the workspace and pie ring with 5-argument calls, paints the selection beam with Canvas 2D arcs and updates hit geometry.

How it works

Both the workspace card (#pm-workspace) and the six-button pie ring (#pm-ring) sit inside one <canvas content="drawable" layoutsubtree> backed by one ElementGL WebGL 2 context from /lib/element-gl.js. I set gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true) on startup and inside onRestored so anti-aliased button edges and rounded borders blend cleanly over the workspace without dark fringes.

Uploading waits until the first paint event sets hasPainted = true, and every frame calls stage.begin() before stage.upload(). Pass 0 draws #pm-workspace 1:1 while sampling nearby texels inside an annular frosted-glass mask centred at uMenuCenter, then overlays sector hairlines, an outer specular arc and the directional selection beam along uPointerAngle. Pass 1 draws #pm-ring with a centre-pinned barrel bulge around the armed wedge and a bright alpha-edge border glow.

Moving a pointer over the ring, dragging outward from any tap point or tabbing onto a button picks the nearest 60° sector and pulls that <button> outward along its polar angle in CSS while scaling it to 1.12×. Because WebGL quads don't move DOM hit regions on their own, syncGeometry() maps #pm-ring to (menuX, menuY) via canvas.updateElementGeometry() scaled by geometryUnit() and toggles dataset.hitTick. Once the springs settle, or when the canvas scrolls off screen or the tab hides, the requestAnimationFrame loop stops. Without WebGL 2, draw2DFallback() renders with 5-argument drawElementImage() calls, and on webglcontextlost both children move into #plain-host as a 3×2 button grid.

Live checks

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

Findings