MCPcopy Create free account
hub / github.com/AmazingAng/PolyWorld / scorePreviewRect

Function scorePreviewRect

src/hooks/usePanelDrag.ts:260–273  ·  view source on GitHub ↗
(clientX: number, clientY: number, rect: DOMRect)

Source from the content-addressed store, hash-verified

258}
259
260function scorePreviewRect(clientX: number, clientY: number, rect: DOMRect) {
261 const outsideDistance = distanceToRect(clientX, clientY, rect);
262 const centerX = rect.left + rect.width / 2;
263 const centerY = rect.top + rect.height / 2;
264 const dx = clientX - centerX;
265 const dy = clientY - centerY;
266 const centerDistance = dx * dx + dy * dy;
267
268 if (outsideDistance === 0) {
269 return centerDistance;
270 }
271
272 return outsideDistance * 16 + centerDistance;
273}
274
275function getPointerGridCell(metrics: ContainerMetrics, clientX: number, clientY: number) {
276 const colUnit = metrics.cellWidth + metrics.colGap;

Callers 1

usePanelDragFunction · 0.85

Calls 1

distanceToRectFunction · 0.85

Tested by

no test coverage detected