X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fcanvas%2Fpoly_item.cc;h=3b2e2efad9a8dafc1760e4c75eaad4e267ae4437;hb=a882e96db1367c26660fd3d3079e9e3e19b1e149;hp=b054b70bbf82efe17f30fc77eeade815d11eb219;hpb=fe6c5612a2c46d6dbad32517d487b120bb8b65c4;p=ardour.git diff --git a/libs/canvas/poly_item.cc b/libs/canvas/poly_item.cc index b054b70bbf..3b2e2efad9 100644 --- a/libs/canvas/poly_item.cc +++ b/libs/canvas/poly_item.cc @@ -64,26 +64,29 @@ PolyItem::compute_bounding_box () const } void -PolyItem::render_path (Rect const & /*area*/, Cairo::RefPtr context) const +PolyItem::render_path (Rect const & /* area */, Cairo::RefPtr context) const { - bool done_first = false; - for (Points::const_iterator i = _points.begin(); i != _points.end(); ++i) { - if (done_first) { - Duple c = item_to_window (Duple (i->x, i->y)); - context->line_to (c.x, c.y); - } else { - Duple c = item_to_window (Duple (i->x, i->y)); - context->move_to (c.x, c.y); - done_first = true; - } + if (_points.size() < 2) { + return; + } + + Points::const_iterator i = _points.begin(); + Duple c (item_to_window (Duple (i->x, i->y))); + const double pixel_adjust = (_outline_width == 1.0 ? 0.5 : 0.0); + + context->move_to (c.x + pixel_adjust, c.y + pixel_adjust); + ++i; + + while (i != _points.end()) { + c = item_to_window (Duple (i->x, i->y)); + context->line_to (c.x + pixel_adjust, c.y + pixel_adjust); + ++i; } } void PolyItem::render_curve (Rect const & area, Cairo::RefPtr context, Points const & first_control_points, Points const & second_control_points) const { - bool done_first = false; - if (_points.size() <= 2) { render_path (area, context); return; @@ -91,26 +94,30 @@ PolyItem::render_curve (Rect const & area, Cairo::RefPtr context Points::const_iterator cp1 = first_control_points.begin(); Points::const_iterator cp2 = second_control_points.begin(); - - for (Points::const_iterator i = _points.begin(); i != _points.end(); ++i) { - - if (done_first) { - - Duple c1 = item_to_window (Duple (cp1->x, cp1->y)); - Duple c2 = item_to_window (Duple (cp2->x, cp2->y)); - Duple c3 = item_to_window (Duple (i->x, i->y)); - - context->curve_to (c1.x, c1.y, c2.x, c2.y, c3.x, c3.y); - - cp1++; - cp2++; - - } else { - - Duple c = item_to_window (Duple (i->x, i->y)); - context->move_to (c.x, c.y); - done_first = true; - } + Points::const_iterator p = _points.begin(); + const double pixel_adjust = (_outline_width == 1.0 ? 0.5 : 0.0); + + Duple c = item_to_window (Duple (p->x, p->y)); + context->move_to (c.x + pixel_adjust, c.y + pixel_adjust); + ++p; + + while (p != _points.end()) { + + Duple c1 = item_to_window (Duple (cp1->x, cp1->y)); + Duple c2 = item_to_window (Duple (cp2->x, cp2->y)); + + c = item_to_window (Duple (p->x, p->y)); + + context->curve_to (c1.x + pixel_adjust, + c1.y + pixel_adjust, + c2.x + pixel_adjust, + c2.y + pixel_adjust, + c.x + pixel_adjust, + c.y + pixel_adjust); + + ++cp1; + ++cp2; + ++p; } }