From d1d4aec900af67c7b42a35bc2fa1ea4fae6435ac Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Fri, 6 Aug 2021 16:08:30 +0200 Subject: [PATCH] Added XY method for Point{,F,F32} that returns the coordinates. --- point.go | 3 +++ pointf.go | 3 +++ pointf32.go | 3 +++ 3 files changed, 9 insertions(+) diff --git a/point.go b/point.go index 92ccc72..73813f6 100644 --- a/point.go +++ b/point.go @@ -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. 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. func MaxPt(a, b Point) Point { return Pt(ints.Max(a.X, b.X), ints.Max(a.Y, b.Y)) diff --git a/pointf.go b/pointf.go index 5ee65d8..437dc58 100644 --- a/pointf.go +++ b/pointf.go @@ -172,6 +172,9 @@ func (p PointF) ToInt() Point { 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. func MaxPtF(a, b PointF) PointF { return PtF(Max(a.X, b.X), Max(a.Y, b.Y)) diff --git a/pointf32.go b/pointf32.go index 1e9c506..f63bad3 100644 --- a/pointf32.go +++ b/pointf32.go @@ -172,6 +172,9 @@ func (p PointF32) ToInt() Point { 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. func MaxPtF32(a, b PointF32) PointF32 { return PtF32(Max32(a.X, b.X), Max32(a.Y, b.Y))