Added XY method for Point{,F,F32} that returns the coordinates.

This commit is contained in:
Sander Schobers 2021-08-06 16:08:30 +02:00
parent 885f27689f
commit d1d4aec900
3 changed files with 9 additions and 0 deletions

View File

@ -136,6 +136,9 @@ func (p Point) ToF() PointF { return PtF(float64(p.X), float64(p.Y)) }
// ToF32 returns the floating point representation of p. // ToF32 returns the floating point representation of p.
func (p Point) ToF32() PointF32 { return PtF32(float32(p.X), float32(p.Y)) } func (p Point) ToF32() PointF32 { return PtF32(float32(p.X), float32(p.Y)) }
// XY returns the X and Y component of the coordinate.
func (p Point) XY() (int, int) { return p.X, p.Y }
// MaxPt returns the point that is at the largest X & Y position of a and b. // MaxPt returns the point that is at the largest X & Y position of a and b.
func MaxPt(a, b Point) Point { func MaxPt(a, b Point) Point {
return Pt(ints.Max(a.X, b.X), ints.Max(a.Y, b.Y)) return Pt(ints.Max(a.X, b.X), ints.Max(a.Y, b.Y))

View File

@ -172,6 +172,9 @@ func (p PointF) ToInt() Point {
return Point{int(p.X), int(p.Y)} return Point{int(p.X), int(p.Y)}
} }
// XY returns the X and Y component of the coordinate.
func (p PointF) XY() (float64, float64) { return p.X, p.Y }
// MaxPtF returns the point that is at the largest X & Y position of a and b. // MaxPtF returns the point that is at the largest X & Y position of a and b.
func MaxPtF(a, b PointF) PointF { func MaxPtF(a, b PointF) PointF {
return PtF(Max(a.X, b.X), Max(a.Y, b.Y)) return PtF(Max(a.X, b.X), Max(a.Y, b.Y))

View File

@ -172,6 +172,9 @@ func (p PointF32) ToInt() Point {
return Point{int(p.X), int(p.Y)} return Point{int(p.X), int(p.Y)}
} }
// XY returns the X and Y component of the coordinate.
func (p PointF32) XY() (float32, float32) { return p.X, p.Y }
// MaxPtF32 returns the point that is at the largest X & Y position of a and b. // MaxPtF32 returns the point that is at the largest X & Y position of a and b.
func MaxPtF32(a, b PointF32) PointF32 { func MaxPtF32(a, b PointF32) PointF32 {
return PtF32(Max32(a.X, b.X), Max32(a.Y, b.Y)) return PtF32(Max32(a.X, b.X), Max32(a.Y, b.Y))