diff --git a/SDL2pp/Rect.cc b/SDL2pp/Rect.cc index 4d1ed40..dd7f1f0 100644 --- a/SDL2pp/Rect.cc +++ b/SDL2pp/Rect.cc @@ -71,4 +71,8 @@ const SDL_Rect* Rect::Get() const { return rect_.get(); } +Rect Rect::FromCenter(int cx, int cy, int w, int h) { + return Rect(cx - w/2, cy - h/2, cx + w - w/2, cy + h - h/2); +} + } diff --git a/SDL2pp/Rect.hh b/SDL2pp/Rect.hh index 4f864e4..cec9faf 100644 --- a/SDL2pp/Rect.hh +++ b/SDL2pp/Rect.hh @@ -41,6 +41,8 @@ public: static Rect Null(); + static Rect FromCenter(int cx, int cy, int w, int h); + Rect(const Rect& other); Rect& operator=(const Rect& other);