(a: HintRect, b: HintRect)
| 110 | |
| 111 | /** Die Flaeche, die zwei Rechtecke gemeinsam haben. Null, wenn sie sich nicht beruehren. */ |
| 112 | export function overlapArea(a: HintRect, b: HintRect): number { |
| 113 | const width = Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x); |
| 114 | const height = Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y); |
| 115 | return width > 0 && height > 0 ? width * height : 0; |
| 116 | } |
| 117 | |
| 118 | /** Einen Wert in einen Bereich zwingen. */ |
| 119 | function clamp(value: number, low: number, high: number): number { |
no outgoing calls
no test coverage detected