Kinetic comic halftone UI
I wanted to know if plain semantic <nav> and <form> HTML can be turned on the GPU into rotated CMYK Ben-Day halftone print with cursor-lit dot radius, chromatic ink-outline offset, diagonal blade-wipe panel transitions and hit-stop shake while staying keyboard-accessible and respecting prefers-reduced-motion: reduce. Pick a print style, sweep across the panel to shift dot gain, or switch between 01 PROFILE and 02 LOADOUT.
Show the code CMYK Ben-Day shader, FBO blade-wipe capture, slanted geometry sync and 2D fallback
- Two semantic HTML panels inside one canvas. The profile
<section>and loadout<form>live inside<canvas content="drawable" layoutsubtree>, withinerthiding whichever panel is off-stage. - Rotated CMYK Ben-Day print shader. Separates un-premultiplied DOM texels into 15, 75, 0 and 45 degree dot screens over paper grain, offsets cyan and magenta edges for chromatic ink outlines and drives dot gain from the cursor spotlight.
- Outgoing FBO capture and 35 ms hit-stop wipe. Copies the outgoing panel into an off-screen framebuffer before switching, holds a 35 ms hit-stop impulse with damped shake (0 px under reduced motion) and slices across with a jagged blade boundary.
- Slanted hit-box calibration. Multiplies the rotated panel
DOMMatrixbygeometryUnit(), callsupdateElementGeometry()on the active panel, moves the inactive panel off-stage and togglesdataset.hitTick. - Five-argument 2D and plain-HTML fallbacks. Draws the tilted panel via 5-argument
drawElementImage()without WebGL 2, or extracts both panels into plain HTML on context loss.
How it works
Both panels live inside one <canvas content="drawable" layoutsubtree> as ordinary drawable HTML: a <section> for the profile card and a <form> for the loadout controls, each carrying its own <nav> tab bar. Because ElementGL creates a single WebGL 2 context for the whole stage, the browser uploads the active panel's DOM pixels with gl.texElementSubImage2D() whenever a control updates or a paint event fires.
In the fragment shader, each sampled RGB texel is un-premultiplied and split into subtractive CMYK channels. Cyan prints on a 15 degree grid, magenta on 75 degrees, yellow on 0 degrees and black on 45 degrees over generated newsprint grain. Dense dark ink above 72% coverage fills solidly so small form labels stay legible even when you widen the dot pitch slider. Cyan and magenta sample slightly offset UVs around dark edges to add print misregistration halos without blurring the black plate.
When you switch tabs in <nav>, the page renders the outgoing panel's current texture into an off-screen RGBA8 framebuffer before swapping inert onto the outgoing panel and enabling the incoming one. Unless reduced motion is active, the next 35 ms holds an impact hit-stop with a damped directional shake before the diagonal jagged blade-wipe clears across to the live incoming texture. Under prefers-reduced-motion: reduce (or the toggle above), shake amplitude drops to 0 px and tabs swap in one frame.
WebGL texture uploads don't move Chromium's hit boxes by themselves. After each frame's transform is computed, comic.js multiplies the slanted panel DOMMatrix by geometryUnit() from /lib/surface.js, calls canvas.updateElementGeometry() on the active panel, pushes the inactive panel off-stage and toggles dataset.hitTick to clear the hit-test cache. If WebGL 2 isn't available, the stage drops to a 2D canvas drawing the tilted panel with five-argument drawElementImage(), or moves both panels into plain HTML on context loss.
Live checks
These checks run on isolated fixtures on the test stage without scrolling or moving focus on the demo above. Tap the button below to run them in this browser.
Findings
- Not verified yet in a live browser: none of the checks or visual modes have been run in headless Chromium 157 or on Chrome 159 for Android yet. Open the page in a browser with HTML-in-canvas enabled and press Run to record measured results.
- Keeping dense key ink solid above 72% coverage while dot-screening mid-tones and coloured gradients lets you push the Ben-Day dot pitch up to 11 px without breaking small labels or input text.
- Duplicating the
<nav>tab bar inside each panel and capturing the outgoing panel into a single off-screen framebuffer lets the diagonal blade-wipe slice through both the old tab indicator and form body in one WebGL draw call, while togglinginertand moving focus keeps keyboard Tab order clean. - Updating
updateElementGeometry()on the active slanted panel and sending the inactive panel off-stage prevents hidden form inputs from intercepting pointer taps in Chromium's hit-test tree.