MCPcopy Create free account
hub / github.com/Noumena-Network/code / intersectClip

Function intersectClip

src/ink/output.ts:134–142  ·  view source on GitHub ↗

* Intersect two clips. `undefined` on an axis means unbounded; the other * clip's bound wins. If both are bounded, take the tighter constraint * (max of mins, min of maxes). If the resulting region is empty * (x1 >= x2 or y1 >= y2), writes clipped by it will be dropped.

(parent: Clip | undefined, child: Clip)

Source from the content-addressed store, hash-verified

132 * (x1 >= x2 or y1 >= y2), writes clipped by it will be dropped.
133 */
134function intersectClip(parent: Clip | undefined, child: Clip): Clip {
135 if (!parent) return child
136 return {
137 x1: maxDefined(parent.x1, child.x1),
138 x2: minDefined(parent.x2, child.x2),
139 y1: maxDefined(parent.y1, child.y1),
140 y2: minDefined(parent.y2, child.y2),
141 }
142}
143
144function maxDefined(
145 a: number | undefined,

Callers 1

getMethod · 0.85

Calls 2

maxDefinedFunction · 0.85
minDefinedFunction · 0.85

Tested by

no test coverage detected