Liquid storage meters and draining digits

I wanted to see if semantic HTML <meter> storage bars and large live <output> quota numerals can serve directly as fluid-filled glass vessels in one WebGL 2 fragment shader. Move the quota slider, press Clear cache or Refill, or drag across the glass dashboard to slosh the layered liquids.

Device storage

Combined
82.0 / 128 GB
128 GB100%
9675%
6450%
3225%
0Empty
Quota used 46.0 GB free
64%
Cache: 18.0 GB Tilt: 0.0°
Apps 28.0 GB 28.0 GB
Media 24.0 GB 24.0 GB
Cache 18.0 GB 18.0 GB
System 12.0 GB 12.0 GB

Starting...

Show the code drawable storage card, fluid glass shader, slosh physics, geometry sync and 2D fallback
  1. Live storage dashboard inside one canvas. Semantic <meter> bars, an <input type="range"> slider, action buttons and a bold <output> readout share one drawable container.
  2. Luminance-masked liquid glass fragment shader. Detects the bright tank, semantic <meter> tracks and <output> numerals from texElementSubImage2D(), refracts etched tank labels and layers sloshing coloured bands.
  3. Damped drain and slosh physics. Integrates target fill levels, angular tilt velocity and wave energy, settling to sleep when idle or snapping immediately under prefers-reduced-motion: reduce.
  4. Hit-test calibration with updateElementGeometry(). Measures sub-element UV boxes, scales the card transform by geometryUnit() and flips dataset.hitTick.
  5. Five-argument drawElementImage() 2D and plain HTML fallbacks. Draws wave-clipped layers over the 2D card picture or moves the live DOM card into plain HTML on context loss.

How it works

This experiment rebuilds Alim Joldaspayev's Liquid Storage (original post) alongside Noman Ijaz's Usage Limit Drain (original post) inside one <canvas content="drawable" layoutsubtree> backed by a single ElementGL WebGL 2 context from /lib/element-gl.js. Everything inside #storage-card stays live HTML: four semantic <meter> elements for Apps, Media, Cache and System, an <input type="range"> slider, two buttons and a bold <output> quota readout.

On each paint event, stage.begin() sizes the backing store before stage.upload(cardEl) uploads the card with gl.texElementSubImage2D(). The fragment shader reads DOM luminance directly from uTex inside the measured boxes of the vertical tank, the four <meter> bars and #quota-digits. Outside those vessel regions, the shader outputs uTex untouched so every label, slider thumb and button border stays sharp.

Inside the tank silhouette (lum > 0.28), four stacked fluid bands rise from System at the bottom through Apps and Media to Cache at the top. Each boundary carries a three-harmonic wave surface tilted by uTilt, a bright capillary meniscus rim, buoyant bubbles and chromatic RGB refraction of the etched 128 GB capacity labels painted in #768fb8 behind the tank. Inside #quota-digits, four-tap luminance gradients form glass tube edges around each numeral so the empty upper portion stays readable even when the liquid drains to 15%.

Clearing cache, dragging the slider or swiping horizontally across the card kicks angular velocity and wave energy in a damped oscillator. Once levels and tilt settle (or when the stage scrolls off screen via IntersectionObserver or the tab hides), the animation loop stops completely. Hit boxes stay aligned through updateElementGeometry() scaled by geometryUnit(), with a five-argument drawElementImage() 2D path and a plain HTML fallback if the context is lost.

Live checks

Each check builds an isolated fixture on testStage() without touching the dashboard above. Press Run to run them in this browser.

Findings