LibGfx: Add overloads to Rect's shrink/inflate that accept a Size<T>

This commit is contained in:
Tom 2020-10-04 11:35:22 -06:00 committed by Andreas Kling
parent da8d87c297
commit 6ad6c4ffad

View file

@ -128,6 +128,14 @@ public:
set_height(height() + h);
}
void inflate(const Size<T>& 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<T>& size)
{
set_x(x() + size.width() / 2);
set_width(width() - size.width());
set_y(y() + size.height() / 2);
set_height(height() - size.height());
}
Rect<T> shrunken(T w, T h) const
{
Rect<T> rect = *this;
@ -143,6 +159,13 @@ public:
return rect;
}
Rect<T> shrunken(const Size<T>& size) const
{
Rect<T> rect = *this;
rect.shrink(size);
return rect;
}
Rect<T> inflated(T w, T h) const
{
Rect<T> rect = *this;
@ -150,6 +173,13 @@ public:
return rect;
}
Rect<T> inflated(const Size<T>& size) const
{
Rect<T> rect = *this;
rect.inflate(size);
return rect;
}
Rect<T> translated(T dx, T dy) const
{
Rect<T> rect = *this;