1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:47:35 +00:00

SharedGraphics: Add Rect::center_within(Rect).

This commit is contained in:
Andreas Kling 2019-03-03 13:34:50 +01:00
parent 0e4b7990c0
commit 483e0a5526

View file

@ -196,6 +196,12 @@ public:
Point bottom_left() const { return { left(), bottom() }; } Point bottom_left() const { return { left(), bottom() }; }
Point bottom_right() const { return { right(), 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()); } String to_string() const { return String::format("[%d,%d %dx%d]", x(), y(), width(), height()); }
private: private: