-
Notifications
You must be signed in to change notification settings - Fork 17
/
overlap.go
28 lines (24 loc) · 648 Bytes
/
overlap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package wallutils
// Functions and structs for detecting overlap between monitors / display configurations
import (
"image"
)
// NewRect is a convenience function for creating an image.Rectangle, given
// the upper left corner (x and y), a width and a height.
func NewRect(x, y, w, h uint) image.Rectangle {
return image.Rect(int(x), int(y), int(x+w), int(y+h))
}
// Overlaps checks if any rectangles in a slice of rectangles overlaps.
func Overlaps(rects []image.Rectangle) bool {
for _, ar := range rects {
for _, br := range rects {
if ar == br {
continue
}
if ar.Overlaps(br) {
return true
}
}
}
return false
}