       const ix = lastStamp.x + dx * t;
          const iy = lastStamp.y + dy * t;
          spawnBrush(ix, iy);
        }
        lastStamp.x = pointer.x; lastStamp.y = pointer.y;
      }
    }
    function onPointerUp(){ state.painting = false; }
    canvas.addEventListener('pointerdown', onPointerDown);
    window.addEventListener('pointermove', onPointerMove);
    window.addEventListener('pointerup', onPointerUp);
    window.addEventListener('pointercancel', onPointerUp);

    const brushesEl = document