mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:07:35 +00:00
Point: Add operator+=, operator-=, and Point+Point
This commit is contained in:
parent
8b38518d0e
commit
57e73e4533
1 changed files with 15 additions and 0 deletions
|
@ -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()); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue