cables.js node wires, but physical
Pluck a wire. Hold Z and draw across wires to zip-tie them. Hold X to cut. Drag from to plug in. One file, no dependencies.
Drop cables.js next to any node UI. Ports are plain elements; the wires live on one canvas over your graph.
import { cables } from './cables.js';
const wires = cables(document.querySelector('canvas'), { slack: 1.12 });
wires.connect(outPort, inPort, { color: '#ff6a2b' });
wires.interact(graphEl, { mode: () => mode }); // pluck, tie, cut, plug
wires.start();
connect(a, b, {color}) | Wire an output element to an input element. |
plug(port).move(x, y).drop(input) | Drag a new wire out; it snaps into the input or springs back. |
tie(x0, y0, x1, y1) | Zip-tie every wire crossing that line into one bundle. |
cut(x0, y0, x1, y1) | Cut wires (or ties) crossing that line; halves retract into their ports. |
interact(root, {mode}) | Optional pointer wiring for all of the above. |
step(dt) · draw() · start() | Verlet ropes at 120 Hz substeps; drive it yourself or let it run. |
set({slack, gravity, stiffness, width}) | Tune the feel live. |