mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:17:35 +00:00
SharedGraphics: Add Rect::center_within(Rect).
This commit is contained in:
parent
0e4b7990c0
commit
483e0a5526
1 changed files with 6 additions and 0 deletions
|
@ -196,6 +196,12 @@ public:
|
|||
Point bottom_left() const { return { left(), bottom() }; }
|
||||
Point bottom_right() const { return { right(), bottom() }; }
|
||||
|
||||
void center_within(const Rect& other)
|
||||
{
|
||||
set_x(other.center().x() - width() / 2);
|
||||
set_y(other.center().y() - height() / 2);
|
||||
}
|
||||
|
||||
String to_string() const { return String::format("[%d,%d %dx%d]", x(), y(), width(), height()); }
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue