mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 09:58:14 +00:00
LibGfx: Add Rect::centered_on()
This is a helper function for creating Rects of a given Size centered on a Point.
This commit is contained in:
parent
11158c2400
commit
30c831a3be
1 changed files with 5 additions and 0 deletions
|
@ -422,6 +422,11 @@ public:
|
|||
|
||||
void intersect(const Rect<T>&);
|
||||
|
||||
static Rect<T> centered_on(const Point<T>& center, const Size<T>& size)
|
||||
{
|
||||
return { { center.x() - size.width() / 2, center.y() - size.height() / 2 }, size };
|
||||
}
|
||||
|
||||
static Rect<T> from_two_points(const Point<T>& a, const Point<T>& b)
|
||||
{
|
||||
return { min(a.x(), b.x()), min(a.y(), b.y()), abst(a.x() - b.x()), abst(a.y() - b.y()) };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue