Revision: 8699 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8699&view=rev Author: mdboom Date: 2010-09-14 15:21:21 +0000 (Tue, 14 Sep 2010)
Log Message: ----------- Fix semi-transparent Gouraud triangle rendering in SVG backend. Modified Paths: -------------- branches/v1_0_maint/lib/matplotlib/backends/backend_svg.py Modified: branches/v1_0_maint/lib/matplotlib/backends/backend_svg.py =================================================================== --- branches/v1_0_maint/lib/matplotlib/backends/backend_svg.py 2010-09-11 19:13:32 UTC (rev 8698) +++ branches/v1_0_maint/lib/matplotlib/backends/backend_svg.py 2010-09-14 15:21:21 UTC (rev 8699) @@ -325,6 +325,11 @@ # opposite edge. Underlying these three gradients is a solid # triangle whose color is the average of all three points. + avg_color = np.sum(colors[:, :], axis=0) / 3.0 + # Just skip fully-transparent triangles + if avg_color[-1] == 0.0: + return + trans_and_flip = self._make_flip_transform(trans) tpoints = trans_and_flip.transform(points) write = self._svgwriter.write @@ -334,7 +339,7 @@ x1, y1 = points[i] x2, y2 = points[(i + 1) % 3] x3, y3 = points[(i + 2) % 3] - c = colors[i][:3] + c = colors[i][:] if x2 == x3: xb = x2 @@ -352,8 +357,8 @@ write('<linearGradient id="GR%x_%d" x1="%f" y1="%f" x2="%f" y2="%f" gradientUnits="userSpaceOnUse">' % (self._n_gradients, i, x1, y1, xb, yb)) - write('<stop offset="0" stop-color="%s" stop-opacity="1.0"/>' % rgb2hex(c)) - write('<stop offset="1" stop-color="%s" stop-opacity="0.0"/>' % rgb2hex(c)) + write('<stop offset="0" style="stop-color:%s;stop-opacity:%f"/>' % (rgb2hex(c), c[-1])) + write('<stop offset="1" style="stop-color:%s;stop-opacity:0"/>' % rgb2hex(c)) write('</linearGradient>') # Define the triangle itself as a "def" since we use it 4 times @@ -361,11 +366,11 @@ (self._n_gradients, x1, y1, x2, y2, x3, y3)) write('</defs>\n') - avg_color = np.sum(colors[:, :3], axis=0) / 3.0 - write('<use xlink:href="#GT%x" fill="%s"/>\n' % - (self._n_gradients, rgb2hex(avg_color))) + avg_color = np.sum(colors[:, :], axis=0) / 3.0 + write('<use xlink:href="#GT%x" fill="%s" fill-opacity="%f"/>\n' % + (self._n_gradients, rgb2hex(avg_color), avg_color[-1])) for i in range(3): - write('<use xlink:href="#GT%x" fill="url(#GR%x_%d)" filter="url(#colorAdd)"/>\n' % + write('<use xlink:href="#GT%x" fill="url(#GR%x_%d)" fill-opacity="1" filter="url(#colorAdd)"/>\n' % (self._n_gradients, self._n_gradients, i)) self._n_gradients += 1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins