From 1dca2841da6f024f613d6dc16de456d5035f8fce Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 31 Oct 2021 22:53:11 +0800 Subject: ... --- include/cru/platform/GraphicsBase.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/cru/platform/GraphicsBase.hpp') diff --git a/include/cru/platform/GraphicsBase.hpp b/include/cru/platform/GraphicsBase.hpp index aee718a1..73b41bb5 100644 --- a/include/cru/platform/GraphicsBase.hpp +++ b/include/cru/platform/GraphicsBase.hpp @@ -206,6 +206,19 @@ struct Rect final { point.y < GetBottom(); } + constexpr Rect Normalize() const { + Rect result = *this; + if (result.width < 0) { + result.left += result.width; + result.width = -result.width; + } + if (result.height < 0) { + result.top += result.height; + result.height = -result.height; + } + return result; + } + float left = 0.0f; float top = 0.0f; float width = 0.0f; -- cgit v1.2.3