Skip to content

Commit

Permalink
Merged revisions 8699-8700 via svnmerge from
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mdboom committed Sep 14, 2010
1 parent e16060e commit d8c86dc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions lib/matplotlib/backends/backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ def draw_gouraud_triangle(self, gc, points, colors, trans):
# 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
Expand All @@ -334,7 +339,7 @@ def draw_gouraud_triangle(self, gc, points, colors, trans):
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
Expand All @@ -352,20 +357,20 @@ def draw_gouraud_triangle(self, gc, points, colors, trans):

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
write('<polygon id="GT%x" points="%f %f %f %f %f %f"/>' %
(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
Expand Down
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/axisartist/axis_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ def draw(self, renderer):
if self._invalid:
self.recache()

if not self._visible: return
renderer.open_group('line2d')

if not self._visible: return
gc = renderer.new_gc()
self._set_gc_clip(gc)

Expand Down

0 comments on commit d8c86dc

Please sign in to comment.