Visual node graph made of live HTML forms
Tools like Blender Shader Nodes, ComfyUI, cables.gl, Rete and React Flow pair graph wires with parameter cards, but zooming DOM nodes with CSS transform blurs text once you pass 150%, while drawing form controls by hand on a canvas throws away browser inputs. After /board/ showed that 2D drawElementImage() re-rasterises DOM vector paint commands sharply at any scale, I built a four-node signal graph of real <form> elements with glowing Bézier wires drawn behind them on one 2D canvas. Drag the background to pan, drag node headers to rearrange, drag or tap ports to rewire, and zoom from 35% to 300%.
Drag empty space to pan, wheel or pinch to zoom (35% to 300%), drag any node header to move it, drag from an output port to an input port (or tap output then input) to rewire, and tap a wired input port to disconnect it.
Show the code Bézier wires, camera zoom and live form nodes on one canvas
- Four live
<form>nodes inside one drawable canvas. Every select, slider, colour input, checkbox, text box and port button stays native HTML. - Evaluating the signal chain from live form values and active wires. Changing a control or rewiring a port recalculates colours, waveform geometry and the SVG swatch inside the Preview node.
- Drawing glowing Bézier wires behind the nodes, then re-rasterising each form at the camera zoom. Wires and optional signal pulses paint first, each visible form paints with 5-argument
drawElementImage(), off-screen nodes park their hit boxes viaupdateElementGeometry(), and the minimap paints last. - Dragging nodes and rewiring ports by pointer or tap. Each port's world coordinate comes from its layout offset inside its form, so wires stay locked to port dots at any zoom level.
How it works
Node-based editors such as Blender Shader Nodes, ComfyUI, cables.gl, Rete and React Flow all face the same browser split: put HTML controls on top of an SVG wire layer and CSS transform: scale() rasterises cards into a bitmap that turns fuzzy at 250% zoom, or draw the whole graph onto a canvas and rebuild every slider, dropdown and text input from scratch. Following /board/, this experiment puts four <form drawable> elements directly inside one <canvas content="drawable" layoutsubtree> and lets one 2D paint handler draw both the wires and the DOM.
On each paint event, the 2D context scales by devicePixelRatio, draws the background dot grid, and strokes every active wire as a horizontal-tangent cubic Bézier curve (an outer glow pass plus a bright core coloured by the live signal). Each visible form node then draws on top under ctx.translate(sx, sy); ctx.scale(cam.k, cam.k); with 5-argument ctx.drawElementImage(node.el, 0, 0, w, h). Because drawElementImage() replays the element's paint commands under the current canvas matrix, labels, borders, inputs and the inline preview SVG re-rasterise cleanly from 35% overview to 300% close-up, and hit-testing tracks the same matrix.
Nodes dragged off screen aren't drawn, so the paint handler calls canvas.updateElementGeometry(node.el, { canvasTransform: OFFSTAGE }) to park their hit boxes away from clicks. After a node drag or camera move finishes, the script toggles a data-hit attribute on moved forms so Chromium clears its hit-test cache without triggering a paint loop. When HTML-in-canvas isn't available or the 2D context fires contextlost, the four forms move into a plain CSS grid with a visible notice so every control keeps working.
Live checks
| Result | Experiment | Detail |
|---|
Findings
- Prior art and inspiration. The node-and-wire interaction follows Blender Shader Nodes, ComfyUI, cables.gl, Rete and React Flow, while the zoomable 2D
drawElementImage()camera builds directly on /board/. - Single-canvas layering removes overlay sync. Drawing glowing cubic Bézier wires first and calling
drawElementImage()for each form afterwards puts wires behind nodes in one coordinate space, with zero DOM z-index clashes and no separate SVG transform matrix to keep aligned during pan and zoom. - Port anchors stay exact from CSS layout offsets. Reading each port button's
offsetToprelative to its<form>gives graph-space coordinates that don't depend on current camera zoom or device scale, so wires stay locked to port dots while dragging or zooming. - Off-screen nodes need explicit hit-box parking. Skipping
drawElementImage()for a culled node leaves its previous hit region active untilupdateElementGeometry()parks it off stage and a DOM attribute toggle clears the hit-test cache. - Verification status. Live browser runs in headless Chromium 157 and Chrome 159 on Android are not verified yet; the six checks above run on isolated fixtures in your browser and report their own pixel and hit-test measurements directly.