package tins2020 import "github.com/veandco/go-sdl2/sdl" type Rectangle struct { sdl.Rect } func RectAbs(x1, y1, x2, y2 int32) Rectangle { if x1 > x2 { x1, x2 = x2, x1 } if y1 > y2 { y1, y2 = y2, y1 } return Rectangle{sdl.Rect{X: x1, Y: y1, W: x2 - x1, H: y2 - y1}} } func Rect(x, y, w, h int32) Rectangle { return Rectangle{sdl.Rect{X: x, Y: y, W: w, H: h}} } func (r Rectangle) Bottom() int32 { return r.Y + r.H } func (r Rectangle) IsPointInside(x, y int32) bool { return x >= r.X && x < r.X+r.W && y >= r.Y && y < r.Y+r.H } func (r Rectangle) IsPointInsidePt(p Point) bool { return r.IsPointInside(p.X, p.Y) } func (r Rectangle) Right() int32 { return r.X + r.W } func (r Rectangle) SDL() sdl.Rect { return r.Rect } func (r Rectangle) SDLPtr() *sdl.Rect { return &r.Rect }