I have an image.Point
and an image.Rectangle
. I'd like to know how to check if the point is in the rectangle. I know that I can manually check with:
p := image.Point{}
r := image.Rect{}
if r.Min.X <= p.X && p.X < r.Max.X && r.Min.Y <= p.Y && p.Y < r.Max.Y {
// Point is in the rectangle!
}
But that is a pain! Is there a better way to do this? I can't find a Contains()
in the documentation.
It’s on Point
, not Rectangle
:
if p.In(r) {
…
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With