mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-03 19:05:59 -04:00
Fix Rect::FromCenter and add test for it
This commit is contained in:
parent
07bf0aa3d5
commit
f6d6572602
@ -93,7 +93,7 @@ const SDL_Rect* Rect::Get() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rect Rect::FromCenter(int cx, int cy, int w, int h) {
|
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);
|
return Rect(cx - w/2, cy - h/2, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Rect::IsNull() const {
|
bool Rect::IsNull() const {
|
||||||
|
@ -119,4 +119,11 @@ BEGIN_TEST()
|
|||||||
|
|
||||||
EXPECT_TRUE(r.GetW() == 16 && r.GetH() == 31);
|
EXPECT_TRUE(r.GetW() == 16 && r.GetH() == 31);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Rect r = Rect::FromCenter(100, 100, 5, 7);
|
||||||
|
|
||||||
|
EXPECT_TRUE(r.GetX() == 98 && r.GetY() == 97);
|
||||||
|
EXPECT_TRUE(r.GetX2() == 102 && r.GetY2() == 103);
|
||||||
|
}
|
||||||
END_TEST()
|
END_TEST()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user