Add another named constructor for Rect

This commit is contained in:
Dmitry Marakasov 2013-09-06 02:03:47 +04:00
parent 8b0b6548f7
commit 3011a62589
2 changed files with 6 additions and 0 deletions

View File

@ -71,4 +71,8 @@ const SDL_Rect* Rect::Get() const {
return rect_.get(); 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);
}
} }

View File

@ -41,6 +41,8 @@ public:
static Rect Null(); static Rect Null();
static Rect FromCenter(int cx, int cy, int w, int h);
Rect(const Rect& other); Rect(const Rect& other);
Rect& operator=(const Rect& other); Rect& operator=(const Rect& other);