summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-01-13 09:28:06 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2014-01-13 09:39:50 -0500
commitfbe94f447000a0fd5af0deffef3f685859b0b32c (patch)
tree4b20da5392c4fbe7ab5c3d0417baeef666a7d444
parentd202fd9ad9b9dd4ccdd25532b01180f268894f13 (diff)
pixel-align canvas PolyItems with single-pixel outlines, for crispness
-rw-r--r--libs/canvas/poly_item.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/libs/canvas/poly_item.cc b/libs/canvas/poly_item.cc
index 69afb5ac24..3b2e2efad9 100644
--- a/libs/canvas/poly_item.cc
+++ b/libs/canvas/poly_item.cc
@@ -72,13 +72,14 @@ PolyItem::render_path (Rect const & /* area */, Cairo::RefPtr<Cairo::Context> co
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, c.y);
+ 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, c.y);
+ context->line_to (c.x + pixel_adjust, c.y + pixel_adjust);
++i;
}
}
@@ -94,9 +95,10 @@ PolyItem::render_curve (Rect const & area, Cairo::RefPtr<Cairo::Context> context
Points::const_iterator cp1 = first_control_points.begin();
Points::const_iterator cp2 = second_control_points.begin();
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, c.y);
+ context->move_to (c.x + pixel_adjust, c.y + pixel_adjust);
++p;
while (p != _points.end()) {
@@ -106,7 +108,12 @@ PolyItem::render_curve (Rect const & area, Cairo::RefPtr<Cairo::Context> context
c = item_to_window (Duple (p->x, p->y));
- context->curve_to (c1.x, c1.y, c2.x, c2.y, c.x, c.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;