diff --git a/Userland/Libraries/LibGfx/Rect.h b/Userland/Libraries/LibGfx/Rect.h index 1ec5f2273d9..6343845a94a 100644 --- a/Userland/Libraries/LibGfx/Rect.h +++ b/Userland/Libraries/LibGfx/Rect.h @@ -612,12 +612,11 @@ using FloatRect = Rect; [[nodiscard]] ALWAYS_INLINE IntRect enclosing_int_rect(FloatRect const& float_rect) { - return { - (int)float_rect.x(), - (int)float_rect.y(), - (int)ceilf(float_rect.width()), - (int)ceilf(float_rect.height()), - }; + int x1 = floorf(float_rect.x()); + int y1 = floorf(float_rect.y()); + int x2 = ceilf(float_rect.x() + float_rect.width()); + int y2 = ceilf(float_rect.y() + float_rect.height()); + return Gfx::IntRect::from_two_points({ x1, y1 }, { x2, y2 }); } }