mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:57:45 +00:00
LibGfx: Add rounded_int_rect() function for Rects
We were seeing a problem in LibWeb, where layout elements would be 1px larger than they should be, due to layout positions using float values, and then converting using `enclosing_int_rect()`. `rounded_int_rect()` replaces that use, by maintaining the original rect's size.
This commit is contained in:
parent
8817ea83d6
commit
0b7eefd4e5
1 changed files with 5 additions and 0 deletions
|
@ -715,6 +715,11 @@ using FloatRect = Rect<float>;
|
||||||
return Gfx::IntRect::from_two_points({ x1, y1 }, { x2, y2 });
|
return Gfx::IntRect::from_two_points({ x1, y1 }, { x2, y2 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] ALWAYS_INLINE IntRect rounded_int_rect(FloatRect const& float_rect)
|
||||||
|
{
|
||||||
|
return IntRect { floorf(float_rect.x()), floorf(float_rect.y()), roundf(float_rect.width()), roundf(float_rect.height()) };
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue