diff options
author | bunnei <bunneidev@gmail.com> | 2016-11-16 01:57:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-16 01:57:08 +0100 |
commit | 5a31552764dc8970253e642f4b829a8b785375c6 (patch) | |
tree | 8186a82c37ae04c17bd1d6250c524fc097f9671c /src/common/math_util.h | |
parent | Merge pull request #2171 from jroweboy/fix-mac-build (diff) | |
parent | Round the rectangle size to prevent float to int casting issues (diff) | |
download | yuzu-5a31552764dc8970253e642f4b829a8b785375c6.tar yuzu-5a31552764dc8970253e642f4b829a8b785375c6.tar.gz yuzu-5a31552764dc8970253e642f4b829a8b785375c6.tar.bz2 yuzu-5a31552764dc8970253e642f4b829a8b785375c6.tar.lz yuzu-5a31552764dc8970253e642f4b829a8b785375c6.tar.xz yuzu-5a31552764dc8970253e642f4b829a8b785375c6.tar.zst yuzu-5a31552764dc8970253e642f4b829a8b785375c6.zip |
Diffstat (limited to 'src/common/math_util.h')
-rw-r--r-- | src/common/math_util.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/common/math_util.h b/src/common/math_util.h index 41d89666c..cdeaeb733 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h @@ -38,6 +38,16 @@ struct Rectangle { T GetHeight() const { return std::abs(static_cast<typename std::make_signed<T>::type>(bottom - top)); } + Rectangle<T> TranslateX(const T x) const { + return Rectangle{left + x, top, right + x, bottom}; + } + Rectangle<T> TranslateY(const T y) const { + return Rectangle{left, top + y, right, bottom + y}; + } + Rectangle<T> Scale(const float s) const { + return Rectangle{left, top, static_cast<T>(left + GetWidth() * s), + static_cast<T>(top + GetHeight() * s)}; + } }; } // namespace MathUtil |