fix: show widget in center of figure

This commit is contained in:
2026-06-23 22:54:20 +05:00
parent ab84d7edfa
commit 9fec5884f8
+7 -3
View File
@@ -40,13 +40,17 @@ export function renderSVG(svg, state) {
} }
svg.appendChild(gridG); svg.appendChild(gridG);
const cx = state.corners.reduce((s, c) => s + c.x, 0) / 4;
const cy = state.corners.reduce((s, c) => s + c.y, 0) / 4;
const widgetRect = document.createElementNS(ns, 'rect'); const widgetRect = document.createElementNS(ns, 'rect');
setAttrs(widgetRect, { setAttrs(widgetRect, {
x: 0, y: 0, x: cx - state.widgetW / 2,
y: cy - state.widgetH / 2,
width: state.widgetW, width: state.widgetW,
height: state.widgetH, height: state.widgetH,
fill: 'none', fill: 'rgba(88,166,255,0.12)',
stroke: 'rgba(88,166,255,0.2)', stroke: 'rgba(88,166,255,0.4)',
'stroke-width': 2, 'stroke-width': 2,
'stroke-dasharray': '12,8' 'stroke-dasharray': '12,8'
}); });