MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / tryAt

Function tryAt

graph-ui/src/galaxy/path-frame.ts:105–112  ·  view source on GitHub ↗
(t: number, side: number)

Source from the content-addressed store, hash-verified

103 const others = [...blockers, ...placed];
104 let best: { t: number; side: number; rect: ScreenRect; overlap: number } | undefined;
105 const tryAt = (t: number, side: number) => {
106 const offset = side * step;
107 const x = from.x + (to.x - from.x) * t + normal.x * offset, y = from.y + (to.y - from.y) * t + normal.y * offset;
108 const rect = { left: x - size.width / 2, right: x + size.width / 2, top: y - size.height / 2, bottom: y + size.height / 2 };
109 const overlap = others.reduce((sum, other) => sum + overlapArea(rect, other), 0);
110 if (!best || overlap < best.overlap) best = { t, side, rect, overlap };
111 return overlap === 0;
112 };
113 for (const side of SIDES.filter((value) => Math.abs(value) <= maxSide)) {
114 for (const t of LABEL_STEPS) if (tryAt(t, side)) return best!;
115 }

Callers 1

placeAlongSegmentFunction · 0.85

Calls 2

reduceMethod · 0.80
overlapAreaFunction · 0.70

Tested by

no test coverage detected