MCPcopy
hub / github.com/nilbuild/driver.js / generateStageSvgPathString

Function generateStageSvgPathString

src/overlay.ts:148–171  ·  view source on GitHub ↗
(stage: StageDefinition)

Source from the content-addressed store, hash-verified

146}
147
148function generateStageSvgPathString(stage: StageDefinition) {
149 const windowX = window.innerWidth;
150 const windowY = window.innerHeight;
151
152 const stagePadding = getConfig("stagePadding") || 0;
153 const stageRadius = getConfig("stageRadius") || 0;
154
155 const stageWidth = stage.width + stagePadding * 2;
156 const stageHeight = stage.height + stagePadding * 2;
157
158 // prevent glitches when stage is too small for radius
159 const limitedRadius = Math.min(stageRadius, stageWidth / 2, stageHeight / 2);
160
161 // no value below 0 allowed + round down
162 const normalizedRadius = Math.floor(Math.max(limitedRadius, 0));
163
164 const highlightBoxX = stage.x - stagePadding + normalizedRadius;
165 const highlightBoxY = stage.y - stagePadding;
166 const highlightBoxWidth = stageWidth - normalizedRadius * 2;
167 const highlightBoxHeight = stageHeight - normalizedRadius * 2;
168
169 return `M${windowX},0L0,0L0,${windowY}L${windowX},${windowY}L${windowX},0Z
170 M${highlightBoxX},${highlightBoxY} h${highlightBoxWidth} a${normalizedRadius},${normalizedRadius} 0 0 1 ${normalizedRadius},${normalizedRadius} v${highlightBoxHeight} a${normalizedRadius},${normalizedRadius} 0 0 1 -${normalizedRadius},${normalizedRadius} h-${highlightBoxWidth} a${normalizedRadius},${normalizedRadius} 0 0 1 -${normalizedRadius},-${normalizedRadius} v-${highlightBoxHeight} a${normalizedRadius},${normalizedRadius} 0 0 1 ${normalizedRadius},-${normalizedRadius} z`;
171}
172
173export function destroyOverlay() {
174 const overlaySvg = getState("__overlaySvg");

Callers 2

renderOverlayFunction · 0.85
createOverlaySvgFunction · 0.85

Calls 1

getConfigFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…