Velocity-driven Disney motion smear and squash-stretch

I wanted to know if one ElementGL canvas can stretch, squash and smear a live HTML card from its instantaneous velocity, then snap back to crisp 1:1 text and hit-testing when it stops. Drag and fling the card, press Fling card, or toggle Figure-8 orbit.

STUDIO EMBER
0 pings
Drag, fling or tap +1 Ping
starting...

Show the code Live drawable card, 2D spring-damper physics, squash-stretch smear shader and hit sync
  1. Live card inside one drawable canvas. #ms-card sits inside <canvas id="ms-canvas" content="drawable" layoutsubtree> with an editable label, palette buttons and +1 Ping counter.
  2. 2D momentum, spring-damper physics and hit-box sync. stepCardMotion(state, tMs) bounces softly off stage bounds, couples the figure-8 orbit via a damped spring, and calls updateElementGeometry() with geometryUnit() and data-hit-tick.
  3. Squash-stretch, 16-tap smear and chromatic RGB trail shader. SMEAR_FRAG warps coordinates along uVel with stretch * squash == 1.0, integrates 16 dithered taps with leading warm and trailing cool fringes, and snaps to 1:1 when speed < 0.01.
  4. Premultiplied uploads, 5-arg 2D fallback and context recovery. Turns on UNPACK_PREMULTIPLY_ALPHA_WEBGL, gates stage.upload() on paint after stage.begin(), and moves the card into #plain-host on webglcontextlost.

How it works

One <canvas id="ms-canvas" content="drawable" layoutsubtree> holds #ms-card under a single ElementGL WebGL 2 context from /lib/element-gl.js. Both creation and onRestored turn on gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true) so the rounded borders, colour swatches and text keep clean edges over the dark stage grid. Texture uploads wait for hasPainted = true inside paint after calling stage.begin(), so the backing store matches device pixel ratio before stage.upload() copies the card.

Dragging, flinging, Fling card or Figure-8 orbit drives stepCardMotion(state, tMs) with explicit timestamps. Free flings coast under exponential damping with soft elastic wall rebounds inside the stage margins; Reset centre and Figure-8 orbit pull the card with a 2D spring-damper. Each frame passes the normalised velocity vector uVel to SMEAR_FRAG on a padded local quad so trails never clip at the card border.

Inside SMEAR_FRAG, any frame with speed >= 0.01 computes an area-preserving basis aligned to (vx, vy) (stretch = 1 + 0.24 * min(speed, 2.2), squash = 1 / stretch) and integrates 16 interleaved-gradient-noise taps weighted from the leading edge into the trailing wake, splitting red ahead and blue behind for a chromatic RGB trail. Once speed < 0.01 or Compare crisp 1:1 (no smear) is pressed, the shader takes one direct unpadded texture sample with zero blur. Every position or stretch change updates updateElementGeometry() scaled by geometryUnit() and flips data-hit-tick to clear Chromium's hit-test cache, while IntersectionObserver and document.hidden pause the loop off screen. If WebGL 2 is unavailable or ?route=2d is set, a 5-argument drawElementImage() trail renders instead; on webglcontextlost or ?route=plain, the live card moves into #plain-host as plain HTML.

Live checks

These checks run on isolated fixtures inside testStage() and wait for a tap so opening the page doesn't allocate extra WebGL contexts or move focus.

StatusCheckDetail

Findings