mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +00:00
LibGfx: Add overloads to Rect's shrink/inflate that accept a Size<T>
This commit is contained in:
parent
da8d87c297
commit
6ad6c4ffad
1 changed files with 30 additions and 0 deletions
|
@ -128,6 +128,14 @@ public:
|
||||||
set_height(height() + h);
|
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)
|
void shrink(T w, T h)
|
||||||
{
|
{
|
||||||
set_x(x() + w / 2);
|
set_x(x() + w / 2);
|
||||||
|
@ -136,6 +144,14 @@ public:
|
||||||
set_height(height() - h);
|
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> shrunken(T w, T h) const
|
||||||
{
|
{
|
||||||
Rect<T> rect = *this;
|
Rect<T> rect = *this;
|
||||||
|
@ -143,6 +159,13 @@ public:
|
||||||
return rect;
|
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> inflated(T w, T h) const
|
||||||
{
|
{
|
||||||
Rect<T> rect = *this;
|
Rect<T> rect = *this;
|
||||||
|
@ -150,6 +173,13 @@ public:
|
||||||
return rect;
|
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> translated(T dx, T dy) const
|
||||||
{
|
{
|
||||||
Rect<T> rect = *this;
|
Rect<T> rect = *this;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue