diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-09-27 18:59:00 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-09-27 18:59:50 +0200 |
commit | 57e73e45339054eb60d5e4fa877fbc91de110d9d (patch) | |
tree | 6c4f39544e30a8bec5b3299d2531bce16ec93fce /Libraries/LibDraw | |
parent | 8b38518d0e405de6002bfcddb96d256a98c01120 (diff) | |
download | serenity-57e73e45339054eb60d5e4fa877fbc91de110d9d.zip |
Point: Add operator+=, operator-=, and Point+Point
Diffstat (limited to 'Libraries/LibDraw')
-rw-r--r-- | Libraries/LibDraw/Point.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Libraries/LibDraw/Point.h b/Libraries/LibDraw/Point.h index 7da91eddc2..e8516ce6c8 100644 --- a/Libraries/LibDraw/Point.h +++ b/Libraries/LibDraw/Point.h @@ -62,7 +62,22 @@ public: } Point operator-() const { return { -m_x, -m_y }; } + Point operator-(const Point& other) const { return { m_x - other.m_x, m_y - other.m_y }; } + Point& operator-=(const Point& other) + { + m_x -= other.m_x; + m_y -= other.m_y; + return *this; + } + + Point& operator+=(const Point& other) + { + m_x += other.m_x; + m_y += other.m_y; + return *this; + } + Point operator+(const Point& other) const { return { m_x + other.m_x, m_y + other.m_y }; } operator WSAPI_Point() const; String to_string() const { return String::format("[%d,%d]", x(), y()); } |