diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2012-11-23 20:47:23 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-18 19:34:20 +0100 |
commit | 579463633c120d5097aae00083ceff5970170114 (patch) | |
tree | 2a54bffce0f2b8521d2d06535af114d6a7120f7b | |
parent | 6901f994667dbc2fd18eb23bb4ed1aae88929200 (diff) | |
download | usdx-579463633c120d5097aae00083ceff5970170114.tar.gz usdx-579463633c120d5097aae00083ceff5970170114.tar.xz usdx-579463633c120d5097aae00083ceff5970170114.zip |
utils/rectangle: add + and =+ operator to move rectangle
Points could be added to rectangles and moves the rectangle by this
amount.
Diffstat (limited to '')
-rw-r--r-- | src/utils/rectangle.hpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/utils/rectangle.hpp b/src/utils/rectangle.hpp index 7297cf47..5ea2787f 100644 --- a/src/utils/rectangle.hpp +++ b/src/utils/rectangle.hpp @@ -144,6 +144,25 @@ namespace usdx return result; } + + const Rectangle<T> operator+(const Point<T>& offset) + { + Rectangle<T> tmp(*this); + tmp += offset; + return tmp; + } + + Rectangle<T>& operator+=(const Point<T>& offset) + { + T height = this->get_height(); + T width = this->get_width(); + T left = this->get_left() + offset.get_x(); + T top = this->get_top() + offset.get_y(); + + this->point1 = Point<T>(left, top); + this->point2 = Point<T>(left + width, top + height); + return *this; + } }; }; |