diff options
| author | 2016-11-05 01:47:05 -0600 | |
|---|---|---|
| committer | 2016-11-05 02:55:58 -0600 | |
| commit | 5f72aade771ea63eaee468b09e2017dbbc5e6bef (patch) | |
| tree | 71ef0b68d767807023e4c4231db5bdc9101c1534 /src/common/math_util.h | |
| parent | LargeFrameLayout + Swapped (diff) | |
| download | yuzu-5f72aade771ea63eaee468b09e2017dbbc5e6bef.tar.gz yuzu-5f72aade771ea63eaee468b09e2017dbbc5e6bef.tar.xz yuzu-5f72aade771ea63eaee468b09e2017dbbc5e6bef.zip | |
Rework frame layouts to use a max rectangle instead of hardcoded calculations
Diffstat (limited to 'src/common/math_util.h')
| -rw-r--r-- | src/common/math_util.h | 12 |
1 files changed, 12 insertions, 0 deletions
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 { | |||
| 38 | T GetHeight() const { | 38 | T GetHeight() const { |
| 39 | return std::abs(static_cast<typename std::make_signed<T>::type>(bottom - top)); | 39 | return std::abs(static_cast<typename std::make_signed<T>::type>(bottom - top)); |
| 40 | } | 40 | } |
| 41 | Rectangle<T> TranslateX(const T x) const { | ||
| 42 | return Rectangle{left + x, top, right + x, bottom}; | ||
| 43 | } | ||
| 44 | Rectangle<T> TranslateY(const T y) const { | ||
| 45 | return Rectangle{left, top + y, right, bottom + y}; | ||
| 46 | } | ||
| 47 | Rectangle<T> Scale(const float s) const { | ||
| 48 | ASSERT(s > 0); | ||
| 49 | return Rectangle { | ||
| 50 | left, top, static_cast<T>((right + left) * s), static_cast<T>((top + bottom) * s) | ||
| 51 | }; | ||
| 52 | } | ||
| 41 | }; | 53 | }; |
| 42 | 54 | ||
| 43 | } // namespace MathUtil | 55 | } // namespace MathUtil |