diff --git a/Libraries/LibGfx/Rect.h b/Libraries/LibGfx/Rect.h index 8697587283..37693555d3 100644 --- a/Libraries/LibGfx/Rect.h +++ b/Libraries/LibGfx/Rect.h @@ -128,6 +128,14 @@ public: set_height(height() + h); } + void inflate(const Size& size) + { + set_x(x() - size.width() / 2); + set_width(width() + size.width()); + set_y(y() - size.height() / 2); + set_height(height() + size.height()); + } + void shrink(T w, T h) { set_x(x() + w / 2); @@ -136,6 +144,14 @@ public: set_height(height() - h); } + void shrink(const Size& size) + { + set_x(x() + size.width() / 2); + set_width(width() - size.width()); + set_y(y() + size.height() / 2); + set_height(height() - size.height()); + } + Rect shrunken(T w, T h) const { Rect rect = *this; @@ -143,6 +159,13 @@ public: return rect; } + Rect shrunken(const Size& size) const + { + Rect rect = *this; + rect.shrink(size); + return rect; + } + Rect inflated(T w, T h) const { Rect rect = *this; @@ -150,6 +173,13 @@ public: return rect; } + Rect inflated(const Size& size) const + { + Rect rect = *this; + rect.inflate(size); + return rect; + } + Rect translated(T dx, T dy) const { Rect rect = *this;