Revision: 8407
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8407&view=rev
Author:   mdboom
Date:     2010-06-10 17:04:44 +0000 (Thu, 10 Jun 2010)

Log Message:
-----------
[2908399] Support clip paths in QuadMesh with gouraud shading

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
    trunk/matplotlib/src/_backend_agg.cpp

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py     2010-06-10 
14:06:50 UTC (rev 8406)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py     2010-06-10 
17:04:44 UTC (rev 8407)
@@ -370,6 +370,24 @@
 
         self._n_gradients += 1
 
+    def draw_gouraud_triangles(self, gc, triangles_array, colors_array,
+                               transform):
+        write = self._svgwriter.write
+
+        clipid = self._get_gc_clip_svg(gc)
+        if clipid is None:
+            clippath = ''
+        else:
+            clippath = 'clip-path="url(#%s)"' % clipid
+
+        write('<g %s>\n' % clippath)
+
+        transform = transform.frozen()
+        for tri, col in zip(triangles_array, colors_array):
+            self.draw_gouraud_triangle(gc, tri, col, transform)
+
+        write('</g>\n')
+
     def draw_image(self, gc, x, y, im):
         # MGDTODO: Support clippath here
         trans = [1,0,0,1,0,0]

Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp       2010-06-10 14:06:50 UTC (rev 
8406)
+++ trunk/matplotlib/src/_backend_agg.cpp       2010-06-10 17:04:44 UTC (rev 
8407)
@@ -1532,7 +1532,7 @@
   theRasterizer.reset_clipping();
   rendererBase.reset_clipping(true);
   set_clipbox(gc.cliprect, theRasterizer);
-  /* TODO: Support clip paths */
+  bool has_clippath = render_clippath(gc.clippath, gc.clippath_trans);
 
   trans *= agg::trans_affine_scaling(1.0, -1.0);
   trans *= agg::trans_affine_translation(0.0, (double)height);
@@ -1560,7 +1560,19 @@
 
   theRasterizer.add_path(span_gen);
 
-  agg::render_scanlines_aa(theRasterizer, slineP8, rendererBase, span_alloc, 
span_gen);
+  if (has_clippath) {
+    typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> 
pixfmt_amask_type;
+    typedef agg::renderer_base<pixfmt_amask_type>              amask_ren_type;
+    typedef agg::renderer_scanline_aa<amask_ren_type, span_alloc_t, span_gen_t>
+      amask_aa_renderer_type;
+
+    pixfmt_amask_type pfa(pixFmt, alphaMask);
+    amask_ren_type r(pfa);
+    amask_aa_renderer_type ren(r, span_alloc, span_gen);
+    agg::render_scanlines(theRasterizer, slineP8, ren);
+  } else {
+    agg::render_scanlines_aa(theRasterizer, slineP8, rendererBase, span_alloc, 
span_gen);
+  }
 }
 
 Py::Object


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to