## matplotlib-checkins

 SF.net SVN: matplotlib:[8699] branches/v1_0_maint/lib/matplotlib/backends/ backend_svg.py From: - 2010-09-14 15:21:30 ```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('' % (self._n_gradients, i, x1, y1, xb, yb)) - write('' % rgb2hex(c)) - write('' % rgb2hex(c)) + write('' % (rgb2hex(c), c[-1])) + write('' % rgb2hex(c)) write('') # 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('\n') - avg_color = np.sum(colors[:, :3], axis=0) / 3.0 - write('\n' % - (self._n_gradients, rgb2hex(avg_color))) + avg_color = np.sum(colors[:, :], axis=0) / 3.0 + write('\n' % + (self._n_gradients, rgb2hex(avg_color), avg_color[-1])) for i in range(3): - write('\n' % + write('\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. ```
 SF.net SVN: matplotlib:[8842] branches/v1_0_maint/lib/matplotlib/backends/ backend_svg.py From: - 2010-12-17 17:58:05 ```Revision: 8842 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8842&view=rev Author: mdboom Date: 2010-12-17 17:57:59 +0000 (Fri, 17 Dec 2010) Log Message: ----------- Fix Unicode encoding error saving SVGs with Unicode characters on some platforms 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-12-14 17:37:42 UTC (rev 8841) +++ branches/v1_0_maint/lib/matplotlib/backends/backend_svg.py 2010-12-17 17:57:59 UTC (rev 8842) @@ -860,7 +860,7 @@ if is_string_like(filename): fh_to_close = svgwriter = codecs.open(filename, 'w', 'utf-8') elif is_writable_file_like(filename): - svgwriter = codecs.EncodedFile(filename, 'utf-8') + svgwriter = codecs.getwriter('utf-8')(filename) fh_to_close = None else: raise ValueError("filename must be a path or a file-like object") @@ -869,10 +869,10 @@ def print_svgz(self, filename, *args, **kwargs): if is_string_like(filename): gzipwriter = gzip.GzipFile(filename, 'w') - fh_to_close = svgwriter = codecs.EncodedFile(gzipwriter, 'utf-8') + fh_to_close = svgwriter = codecs.getwriter('utf-8')(gzipwriter) elif is_writable_file_like(filename): fh_to_close = gzipwriter = gzip.GzipFile(fileobj=filename, mode='w') - svgwriter = codecs.EncodedFile(gzipwriter, 'utf-8') + svgwriter = codecs.getwriter('utf-8')(gzipwriter) else: raise ValueError("filename must be a path or a file-like object") return self._print_svg(filename, svgwriter, fh_to_close) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```