From 7974f86c4ab669eef16a483048543e02d696ca45 Mon Sep 17 00:00:00 2001
From: faiface <faiface@ksp.sk>
Date: Sat, 25 Feb 2017 18:38:22 +0100
Subject: [PATCH] add Rect.Contains(Vec) bool method

---
 geometry.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/geometry.go b/geometry.go
index 64db6fc..b426686 100644
--- a/geometry.go
+++ b/geometry.go
@@ -151,3 +151,9 @@ func (r Rect) XYWH() (x, y, w, h float64) {
 func (r Rect) Center() Vec {
 	return r.Pos + r.Size.Scaled(0.5)
 }
+
+// Contains checks whether a vector u is contained within this Rect (including it's borders).
+func (r Rect) Contains(u Vec) bool {
+	min, max := r.Pos, r.Pos+r.Size
+	return min.X() <= u.X() && u.X() <= max.X() && min.Y() <= u.Y() && u.Y() <= max.Y()
+}
-- 
GitLab