Skip to content

Commit d8c86dc

Browse files
committed
Merged revisions 8699-8700 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v1_0_maint ........ r8699 | mdboom | 2010-09-14 11:21:21 -0400 (Tue, 14 Sep 2010) | 2 lines Fix semi-transparent Gouraud triangle rendering in SVG backend. ........ r8700 | mdboom | 2010-09-14 11:53:59 -0400 (Tue, 14 Sep 2010) | 2 lines Fix mismatched opening/closing group. ........ svn path=/trunk/matplotlib/; revision=8701
1 parent e16060e commit d8c86dc

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

lib/matplotlib/backends/backend_svg.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,11 @@ def draw_gouraud_triangle(self, gc, points, colors, trans):
325325
# opposite edge. Underlying these three gradients is a solid
326326
# triangle whose color is the average of all three points.
327327

328+
avg_color = np.sum(colors[:, :], axis=0) / 3.0
329+
# Just skip fully-transparent triangles
330+
if avg_color[-1] == 0.0:
331+
return
332+
328333
trans_and_flip = self._make_flip_transform(trans)
329334
tpoints = trans_and_flip.transform(points)
330335
write = self._svgwriter.write
@@ -334,7 +339,7 @@ def draw_gouraud_triangle(self, gc, points, colors, trans):
334339
x1, y1 = points[i]
335340
x2, y2 = points[(i + 1) % 3]
336341
x3, y3 = points[(i + 2) % 3]
337-
c = colors[i][:3]
342+
c = colors[i][:]
338343

339344
if x2 == x3:
340345
xb = x2
@@ -352,20 +357,20 @@ def draw_gouraud_triangle(self, gc, points, colors, trans):
352357

353358
write('<linearGradient id="GR%x_%d" x1="%f" y1="%f" x2="%f" y2="%f" gradientUnits="userSpaceOnUse">' %
354359
(self._n_gradients, i, x1, y1, xb, yb))
355-
write('<stop offset="0" stop-color="%s" stop-opacity="1.0"/>' % rgb2hex(c))
356-
write('<stop offset="1" stop-color="%s" stop-opacity="0.0"/>' % rgb2hex(c))
360+
write('<stop offset="0" style="stop-color:%s;stop-opacity:%f"/>' % (rgb2hex(c), c[-1]))
361+
write('<stop offset="1" style="stop-color:%s;stop-opacity:0"/>' % rgb2hex(c))
357362
write('</linearGradient>')
358363

359364
# Define the triangle itself as a "def" since we use it 4 times
360365
write('<polygon id="GT%x" points="%f %f %f %f %f %f"/>' %
361366
(self._n_gradients, x1, y1, x2, y2, x3, y3))
362367
write('</defs>\n')
363368

364-
avg_color = np.sum(colors[:, :3], axis=0) / 3.0
365-
write('<use xlink:href="#GT%x" fill="%s"/>\n' %
366-
(self._n_gradients, rgb2hex(avg_color)))
369+
avg_color = np.sum(colors[:, :], axis=0) / 3.0
370+
write('<use xlink:href="#GT%x" fill="%s" fill-opacity="%f"/>\n' %
371+
(self._n_gradients, rgb2hex(avg_color), avg_color[-1]))
367372
for i in range(3):
368-
write('<use xlink:href="#GT%x" fill="url(#GR%x_%d)" filter="url(#colorAdd)"/>\n' %
373+
write('<use xlink:href="#GT%x" fill="url(#GR%x_%d)" fill-opacity="1" filter="url(#colorAdd)"/>\n' %
369374
(self._n_gradients, self._n_gradients, i))
370375

371376
self._n_gradients += 1

lib/mpl_toolkits/axisartist/axis_artist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ def draw(self, renderer):
132132
if self._invalid:
133133
self.recache()
134134

135+
if not self._visible: return
135136
renderer.open_group('line2d')
136137

137-
if not self._visible: return
138138
gc = renderer.new_gc()
139139
self._set_gc_clip(gc)
140140

0 commit comments

Comments
 (0)