From 5f72aade771ea63eaee468b09e2017dbbc5e6bef Mon Sep 17 00:00:00 2001 From: James Rowe Date: Sat, 5 Nov 2016 01:47:05 -0600 Subject: Rework frame layouts to use a max rectangle instead of hardcoded calculations --- src/common/math_util.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/common/math_util.h') diff --git a/src/common/math_util.h b/src/common/math_util.h index 41d89666c..570ec8e56 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h @@ -38,6 +38,18 @@ struct Rectangle { T GetHeight() const { return std::abs(static_cast::type>(bottom - top)); } + Rectangle TranslateX(const T x) const { + return Rectangle{left + x, top, right + x, bottom}; + } + Rectangle TranslateY(const T y) const { + return Rectangle{left, top + y, right, bottom + y}; + } + Rectangle Scale(const float s) const { + ASSERT(s > 0); + return Rectangle { + left, top, static_cast((right + left) * s), static_cast((top + bottom) * s) + }; + } }; } // namespace MathUtil -- cgit v1.2.3