move overlaps func to d2
This commit is contained in:
parent
ae508c1d89
commit
a8cc241c22
1 changed files with 6 additions and 0 deletions
|
|
@ -83,3 +83,9 @@ func (b *Box) Contains(p *Point) bool {
|
|||
return !(p.X < b.TopLeft.X || b.TopLeft.X+b.Width < p.X ||
|
||||
p.Y < b.TopLeft.Y || b.TopLeft.Y+b.Height < p.Y)
|
||||
}
|
||||
|
||||
func (b1 Box) Overlaps(b2 Box) bool {
|
||||
// https://silentmatt.com/rectangle-intersection/
|
||||
return (b1.TopLeft.X < (b2.TopLeft.X + b2.Width)) && ((b1.TopLeft.X + b1.Width) > b2.TopLeft.X) &&
|
||||
(b1.TopLeft.Y < (b2.TopLeft.Y + b2.Height)) && ((b1.TopLeft.Y + b1.Height) > b2.TopLeft.Y)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue