diff options
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 |