* 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)
| 132 | * (x1 >= x2 or y1 >= y2), writes clipped by it will be dropped. |
| 133 | */ |
| 134 | function 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 | |
| 144 | function maxDefined( |
| 145 | a: number | undefined, |
no test coverage detected