From e88a121ff88d8f73ae5b10afdd5c296bb456e920 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 7 Sep 2023 02:42:25 +0200 Subject: [PATCH] Fix canvas rectangle bounding box When drawing the outline of a rectangle, the bounding box must cover the whole pixel of the line. Otherwise the line would be left behind when the rectangle shrinks. --- libs/canvas/rectangle.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/canvas/rectangle.cc b/libs/canvas/rectangle.cc index 20ea629519..65a045ce8f 100644 --- a/libs/canvas/rectangle.cc +++ b/libs/canvas/rectangle.cc @@ -170,9 +170,12 @@ Rectangle::size_request (double& w, double& h) const void Rectangle::compute_bounding_box () const { - if (!_rect.empty()) { - // _bounding_box = _rect.fix().expand (1.0 + _outline_width * 0.5); - _bounding_box = _rect.fix().expand (_outline_width * 0.5); + if (_rect.empty ()) { + _bounding_box = Rect (); + } else if (_outline && _outline_width && _outline_what) { + _bounding_box = _rect.fix().expand (ceil (_outline_width * 0.5)); + } else { + _bounding_box = _rect.fix(); } set_bbox_clean ();