mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibGfx: Add overloads to Rect's shrink/inflate that accept a Size<T>
This commit is contained in:
parent
da8d87c297
commit
6ad6c4ffad
Notes:
sideshowbarker
2024-07-19 01:55:12 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/6ad6c4ffad5 Pull-request: https://github.com/SerenityOS/serenity/pull/3751
1 changed files with 30 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue