39 lines
752 B
Go
39 lines
752 B
Go
|
package sdlui
|
||
|
|
||
|
import (
|
||
|
"github.com/veandco/go-sdl2/sdl"
|
||
|
"opslag.de/schobers/geom"
|
||
|
)
|
||
|
|
||
|
func Rect(x, y, w, h int32) sdl.Rect {
|
||
|
return sdl.Rect{X: x, Y: y, W: w, H: h}
|
||
|
}
|
||
|
|
||
|
func RectAbs(x1, y1, x2, y2 int32) sdl.Rect {
|
||
|
if x1 > x2 {
|
||
|
x1, x2 = x2, x1
|
||
|
}
|
||
|
if y1 > y2 {
|
||
|
y1, y2 = y2, y1
|
||
|
}
|
||
|
return Rect(x1, y1, x2-x1, y2-y1)
|
||
|
}
|
||
|
|
||
|
func RectAbsPtr(x1, y1, x2, y2 int32) *sdl.Rect {
|
||
|
rect := RectAbs(x1, y1, x2, y2)
|
||
|
return &rect
|
||
|
}
|
||
|
|
||
|
func RectPtr(x, y, w, h int32) *sdl.Rect {
|
||
|
return &sdl.Rect{X: x, Y: y, W: w, H: h}
|
||
|
}
|
||
|
|
||
|
func SDLRectangle(r geom.RectangleF32) sdl.Rect {
|
||
|
return sdl.Rect{X: int32(r.Min.X), Y: int32(r.Min.Y), W: int32(r.Dx()), H: int32(r.Dy())}
|
||
|
}
|
||
|
|
||
|
func SDLRectanglePtr(r geom.RectangleF32) *sdl.Rect {
|
||
|
rect := SDLRectangle(r)
|
||
|
return &rect
|
||
|
}
|