To work around seams in the rendering of adjacent polygons in the
Cairo drivers' output (examples 8 and 16 in particular), an extra
stroke of the drawn polygons was enabled in the Cairo bindings.  This
has the unfortunate side effect of adding a sort of sawtooth edge in
certain cases, most noticeably in example 8.

The Qt4 drivers do not exhibit this behavior.  I asked around on the
Cairo IRC channel and mailing list and was told that this is, in part,
because (at least some of the time) the Qt4 output /is/ adding an
extra outline stroke around the filled polygons.  However, it does not
seem to do this in all cases (yes in page 1 of example 16, no in page
1 of example 8).  You can test this by importing the PDF output from
either driver in to Inkscape, opening the available groupings and
looking at the fill and stroke properties of an individual polygon.

One fix for the Cairo driver's sawtooth effect suggested on the Cairo
list is to change the line caps and/or joints.  The attached patch
does just that and produces, from what I can tell, output which is
quite nice and without any of those teeth along the edges of the
plotted surfaces in example 8.

I hope that this can be tested and make it in before 5.9.3 is
released!  I realize that this is very short notice, but it provides a
fairly significant improvement in rendering quality on my system.  If
not, then certainly post-5.9.3.

Hez

-- 
Hezekiah M. Carty
Graduate Research Assistant
University of Maryland
Department of Atmospheric and Oceanic Science
diff --git a/drivers/cairo.c b/drivers/cairo.c
index 12a79e5..3a70921 100644
--- a/drivers/cairo.c
+++ b/drivers/cairo.c
@@ -988,9 +988,18 @@ void filled_polygon(PLStream *pls, short *xa, short *ya, PLINT npts)
 {
   int i;
   PLCairo *aStream;
+  cairo_line_join_t old_line_join;
+  cairo_line_cap_t old_line_cap;
 
   aStream = (PLCairo *)pls->dev;
 
+  /* Save the previous line drawing style */
+  old_line_cap = cairo_get_line_cap(aStream->cairoContext);
+  old_line_join = cairo_get_line_join(aStream->cairoContext);
+
+  cairo_set_line_cap(aStream->cairoContext, CAIRO_LINE_CAP_BUTT);
+  cairo_set_line_join(aStream->cairoContext, CAIRO_LINE_JOIN_BEVEL);
+
   cairo_move_to(aStream->cairoContext, aStream->downscale * (double) xa[0], aStream->downscale * (double) ya[0]);
   for(i=1;i<npts;i++)
     cairo_line_to(aStream->cairoContext, aStream->downscale * (double) xa[i], aStream->downscale * (double) ya[i]);
@@ -1005,6 +1014,10 @@ void filled_polygon(PLStream *pls, short *xa, short *ya, PLINT npts)
     cairo_stroke(aStream->cairoContext);
   } else
     cairo_fill(aStream->cairoContext);
+
+  /* Restor the previous line drawing style */
+  cairo_set_line_cap(aStream->cairoContext, old_line_cap);
+  cairo_set_line_join(aStream->cairoContext, old_line_join);
 }
 
 /*---------------------------------------------------------------------
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to