final (?) tweaks to rectangle rendering

This commit is contained in:
Paul Davis 2014-01-10 14:36:05 -05:00
parent 9df593d823
commit 22c303d8f6

View file

@ -67,6 +67,7 @@ Rectangle::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) con
} else { } else {
setup_gradient_context (context, self, Duple (draw.x0, draw.y0)); setup_gradient_context (context, self, Duple (draw.x0, draw.y0));
} }
context->rectangle (draw.x0, draw.y0, draw.width(), draw.height()); context->rectangle (draw.x0, draw.y0, draw.width(), draw.height());
context->fill (); context->fill ();
} }
@ -77,11 +78,17 @@ Rectangle::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) con
if (_outline_what == What (LEFT|RIGHT|BOTTOM|TOP)) { if (_outline_what == What (LEFT|RIGHT|BOTTOM|TOP)) {
context->rectangle (self.x0 + 0.5, self.y0 + 0.5, self.width(), self.height()); /* outline must be on pixels (hence 0.5 offset) and
must be WITHIN coordinates of rect, not outside it
(hence the -2.0 size adjustment, since we use 1
pixel on each side for the outline)
*/
context->rectangle (self.x0 + 0.5, self.y0 + 0.5, self.width() - 1.0, self.height() - 1.0);
} else { } else {
context->set_line_cap (Cairo::LINE_CAP_SQUARE); // context->set_line_cap (Cairo::LINE_CAP_SQUARE);
/* see the cairo FAQ on single pixel lines to see why we do /* see the cairo FAQ on single pixel lines to see why we do
* this expansion of the perimeter. * this expansion of the perimeter.
@ -129,7 +136,7 @@ Rectangle::compute_bounding_box () const
* XXX: or something like that, waffle. * XXX: or something like that, waffle.
* *
*/ */
_bounding_box = r.expand (1.0); _bounding_box = _rect.fix ();
} }
_bounding_box_dirty = false; _bounding_box_dirty = false;