From dce035fec4ed9f8e83407ab5a86b913e3ec0946c Mon Sep 17 00:00:00 2001 From: pierre Date: Tue, 24 Nov 2020 19:43:32 +0100 Subject: [PATCH] f32: added Point.In(Rectangle) Signed-off-by: pierre --- f32/f32.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/f32/f32.go b/f32/f32.go index 798e3bf0..69745ba2 100644 --- a/f32/f32.go +++ b/f32/f32.go @@ -66,6 +66,12 @@ func (p Point) Mul(s float32) Point { return Point{X: p.X * s, Y: p.Y * s} } +// In reports whether p is in r. +func (p Point) In(r Rectangle) bool { + return r.Min.X <= p.X && p.X < r.Max.X && + r.Min.Y <= p.Y && p.Y < r.Max.Y +} + // Size returns r's width and height. func (r Rectangle) Size() Point { return Point{X: r.Dx(), Y: r.Dy()}