MCPcopy
hub / github.com/opentrace/opentrace / computeBounds

Function computeBounds

ui/src/components/pixi/viewport.ts:64–78  ·  view source on GitHub ↗
(
  positions: Iterable<{ x: number; y: number }>,
)

Source from the content-addressed store, hash-verified

62
63/** Compute the bounding box of a set of positions. */
64export function computeBounds(
65 positions: Iterable<{ x: number; y: number }>,
66): Bounds {
67 let minX = Infinity,
68 maxX = -Infinity,
69 minY = Infinity,
70 maxY = -Infinity;
71 for (const p of positions) {
72 if (p.x < minX) minX = p.x;
73 if (p.x > maxX) maxX = p.x;
74 if (p.y < minY) minY = p.y;
75 if (p.y > maxY) maxY = p.y;
76 }
77 return { minX, maxX, minY, maxY };
78}
79
80/** Compute viewport that fits the given bounds into a canvas of (w, h). */
81export function fitBounds(

Callers 3

zoomToFitMethod · 0.90
computeFitTargetMethod · 0.90
zoomToNodesMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected