diff --git a/SDL2pp/Point.cc b/SDL2pp/Point.cc index 3084af7..9c2c1b0 100644 --- a/SDL2pp/Point.cc +++ b/SDL2pp/Point.cc @@ -76,9 +76,19 @@ int Point::GetX() const { return point_->x; } +void Point::SetX(int x) { + assert(!IsNull()); + point_->x = x; +} + int Point::GetY() const { assert(!IsNull()); return point_->y; } +void Point::SetY(int y) { + assert(!IsNull()); + point_->y = y; +} + } diff --git a/SDL2pp/Point.hh b/SDL2pp/Point.hh index 9df36fa..73c153b 100644 --- a/SDL2pp/Point.hh +++ b/SDL2pp/Point.hh @@ -62,7 +62,10 @@ public: bool IsNull() const; int GetX() const; + void SetX(int x); + int GetY() const; + void SetY(int y); }; } diff --git a/SDL2pp/Rect.cc b/SDL2pp/Rect.cc index ce201e2..88a2388 100644 --- a/SDL2pp/Rect.cc +++ b/SDL2pp/Rect.cc @@ -86,29 +86,59 @@ int Rect::GetX() const { return rect_->x; } +void Rect::SetX(int x) { + assert(!IsNull()); + rect_->x = x; +} + int Rect::GetY() const { assert(!IsNull()); return rect_->y; } +void Rect::SetY(int y) { + assert(!IsNull()); + rect_->y = y; +} + int Rect::GetW() const { assert(!IsNull()); return rect_->w; } +void Rect::SetW(int w) { + assert(!IsNull()); + rect_->w = w; +} + int Rect::GetH() const { assert(!IsNull()); return rect_->h; } +void Rect::SetH(int h) { + assert(!IsNull()); + rect_->h = h; +} + int Rect::GetX2() const { assert(!IsNull()); - return rect_->x + rect_->w; + return rect_->x + rect_->w - 1; +} + +void Rect::SetX2(int x2) { + assert(!IsNull()); + rect_->w = x2 - rect_->x + 1; } int Rect::GetY2() const { assert(!IsNull()); - return rect_->y + rect_->h; + return rect_->y + rect_->h - 1; +} + +void Rect::SetY2(int y2) { + assert(!IsNull()); + rect_->h = y2 - rect_->y + 1; } } diff --git a/SDL2pp/Rect.hh b/SDL2pp/Rect.hh index 8c20d84..32211c5 100644 --- a/SDL2pp/Rect.hh +++ b/SDL2pp/Rect.hh @@ -54,11 +54,22 @@ public: bool IsNull() const; int GetX() const; + void SetX(int x); + int GetY() const; + void SetY(int y); + int GetW() const; + void SetW(int w); + int GetH() const; + void SetH(int h); + int GetX2() const; + void SetX2(int x2); + int GetY2() const; + void SetY2(int y2); }; }