From 57e73e45339054eb60d5e4fa877fbc91de110d9d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 27 Sep 2019 18:59:00 +0200 Subject: [PATCH] Point: Add operator+=, operator-=, and Point+Point --- Libraries/LibDraw/Point.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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()); }