MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / portPoint

Function portPoint

ui/src/lib/map-model.ts:579–590  ·  view source on GitHub ↗
(node: MapNodeLayout, id: string, type: 'source' | 'target')

Source from the content-addressed store, hash-verified

577 * one the browser will measure.
578 */
579export function portPoint(node: MapNodeLayout, id: string, type: 'source' | 'target'): { x: number; y: number } {
580 const top = node.ports.top.findIndex((p) => p.id === id && p.type === type);
581 if (top >= 0) return { x: node.x + (node.width * (top + 1)) / (node.ports.top.length + 1), y: node.y };
582 const bottom = node.ports.bottom.findIndex((p) => p.id === id && p.type === type);
583 if (bottom >= 0) {
584 return {
585 x: node.x + (node.width * (bottom + 1)) / (node.ports.bottom.length + 1),
586 y: node.y + node.height,
587 };
588 }
589 return { x: node.x + node.width / 2, y: type === 'source' ? node.y + node.height : node.y };
590}
591
592interface SidePort extends PortRef {
593 /** Centre x of the link's other end — the sort key along the side. */

Callers 4

trackedCurvesFunction · 0.90
placeLabelsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected