From f06c38ff3ebb80655e8460b6e919a3aa5fd08362 Mon Sep 17 00:00:00 2001 From: Noel Berry Date: Mon, 3 Oct 2022 00:30:49 -0700 Subject: [PATCH] added `bool Rect::contains(Rect)` --- include/blah_spatial.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/blah_spatial.h b/include/blah_spatial.h index aaea9cd..4193662 100644 --- a/include/blah_spatial.h +++ b/include/blah_spatial.h @@ -192,6 +192,7 @@ namespace Blah constexpr Line bottom_line() const; constexpr bool contains(const Vec2& pt) const; + constexpr bool contains(const Rect& rect) const; constexpr bool overlaps(const Rect& rect) const; constexpr Rect overlap_rect(const Rect& other) const; constexpr bool intersects(const Line& line) const; @@ -719,6 +720,10 @@ namespace Blah constexpr bool Rect::contains(const Vec2& pt) const { return pt.x >= x && pt.x < x + w && pt.y >= y && pt.y < y + h; } + template + constexpr bool Rect::contains(const Rect& rect) const { + return rect.x >= x && rect.x + rect.w < x + w && rect.y >= y && rect.y + rect.h < y + h; + } template constexpr bool Rect::overlaps(const Rect& rect) const {