diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/rect.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/common/rect.h b/common/rect.h index b4355052f6..2230111538 100644 --- a/common/rect.h +++ b/common/rect.h @@ -189,7 +189,7 @@ struct Rect { } void translate(int16 dx, int16 dy) { - left += dx; right += dx; + left += dx; right += dx; top += dy; bottom += dy; } @@ -200,6 +200,13 @@ struct Rect { void debugPrint(int debuglevel = 0, const char *caption = "Rect:") const { debug(debuglevel, "%s %d, %d, %d, %d", caption, left, top, right, bottom); } + + /*! @brief create a rectangle around the given center */ + static Rect center(int16 cx, int16 cy, int16 w, int16 h) { + w /= 2; + h /= 2; + return Rect(cx - w, cy - h, cx + w, cy + h); + } }; } // End of namespace Common |