mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:37:34 +00:00
LibDraw: Add Rect::from_two_points(Point, Point)
This returns the rectangle between two given Points. Thanks Owlinator for suggesting this much easier way of doing it :^)
This commit is contained in:
parent
32ff660aa5
commit
6685be36a0
2 changed files with 7 additions and 16 deletions
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/LogStream.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibDraw/Orientation.h>
|
||||
#include <LibDraw/Point.h>
|
||||
#include <LibDraw/Size.h>
|
||||
|
@ -237,6 +237,11 @@ public:
|
|||
|
||||
void intersect(const Rect&);
|
||||
|
||||
static Rect from_two_points(const Point& a, const Point& b)
|
||||
{
|
||||
return { min(a.x(), b.x()), min(a.y(), b.y()), abs(a.x() - b.x()), abs(a.y() - b.y()) };
|
||||
}
|
||||
|
||||
static Rect intersection(const Rect& a, const Rect& b)
|
||||
{
|
||||
Rect r(a);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue