summaryrefslogtreecommitdiffstats
path: root/src/common/math_util.h
diff options
context:
space:
mode:
authorJames Rowe <jroweboy@gmail.com>2016-11-05 08:47:05 +0100
committerJames Rowe <jroweboy@gmail.com>2016-11-05 09:55:58 +0100
commit5f72aade771ea63eaee468b09e2017dbbc5e6bef (patch)
tree71ef0b68d767807023e4c4231db5bdc9101c1534 /src/common/math_util.h
parentLargeFrameLayout + Swapped (diff)
downloadyuzu-5f72aade771ea63eaee468b09e2017dbbc5e6bef.tar
yuzu-5f72aade771ea63eaee468b09e2017dbbc5e6bef.tar.gz
yuzu-5f72aade771ea63eaee468b09e2017dbbc5e6bef.tar.bz2
yuzu-5f72aade771ea63eaee468b09e2017dbbc5e6bef.tar.lz
yuzu-5f72aade771ea63eaee468b09e2017dbbc5e6bef.tar.xz
yuzu-5f72aade771ea63eaee468b09e2017dbbc5e6bef.tar.zst
yuzu-5f72aade771ea63eaee468b09e2017dbbc5e6bef.zip
Diffstat (limited to '')
-rw-r--r--src/common/math_util.h12
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 {
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 {
+ ASSERT(s > 0);
+ return Rectangle {
+ left, top, static_cast<T>((right + left) * s), static_cast<T>((top + bottom) * s)
+ };
+ }
};
} // namespace MathUtil