2020-05-08 16:38:26 +00:00
|
|
|
package tins2020
|
|
|
|
|
2020-05-10 10:21:51 +00:00
|
|
|
import "github.com/veandco/go-sdl2/sdl"
|
|
|
|
|
2020-05-08 16:38:26 +00:00
|
|
|
type Point struct {
|
2020-05-10 10:21:51 +00:00
|
|
|
sdl.Point
|
2020-05-08 16:38:26 +00:00
|
|
|
}
|
2020-05-09 11:55:37 +00:00
|
|
|
|
|
|
|
func (p Point) Add(q Point) Point { return Pt(p.X+q.X, p.Y+q.Y) }
|
|
|
|
|
2020-05-10 10:21:51 +00:00
|
|
|
func (p Point) In(r Rectangle) bool { return r.IsPointInsidePt(p) }
|
|
|
|
|
2020-05-09 11:55:37 +00:00
|
|
|
type PointF struct {
|
2020-05-10 10:21:51 +00:00
|
|
|
sdl.FPoint
|
2020-05-09 11:55:37 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 10:21:51 +00:00
|
|
|
func (p PointF) Add(q PointF) PointF {
|
|
|
|
return PtF(p.X+q.X, p.Y+q.Y)
|
|
|
|
}
|
2020-05-09 11:55:37 +00:00
|
|
|
|
|
|
|
func (p PointF) Sub(q PointF) PointF { return PtF(p.X-q.X, p.Y-q.Y) }
|
|
|
|
|
2020-05-10 10:21:51 +00:00
|
|
|
func Pt(x, y int32) Point { return Point{sdl.Point{X: x, Y: y}} }
|
|
|
|
func PtF(x, y float32) PointF { return PointF{sdl.FPoint{X: x, Y: y}} }
|
|
|
|
|
|
|
|
func PtPtr(x, y int32) *Point {
|
|
|
|
p := Pt(x, y)
|
|
|
|
return &p
|
|
|
|
}
|
|
|
|
|
|
|
|
func PtFPtr(x, y float32) *PointF {
|
|
|
|
p := PtF(x, y)
|
|
|
|
return &p
|
|
|
|
}
|