@@ -650,6 +650,8 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
650
650
self ._path_collection_id += 1
651
651
652
652
def draw_gouraud_triangle (self , gc , points , colors , trans ):
653
+ # docstring inherited
654
+
653
655
# This uses a method described here:
654
656
#
655
657
# http://www.svgopen.org/2005/papers/Converting3DFaceToSVG/index.html
@@ -685,9 +687,9 @@ def draw_gouraud_triangle(self, gc, points, colors, trans):
685
687
' \n 1 1 1 1 0 \n 0 0 0 0 1 ' )
686
688
writer .end ('filter' )
687
689
688
- avg_color = np .sum (colors [:, :], axis = 0 ) / 3.0
689
- # Just skip fully-transparent triangles
690
- if avg_color [ - 1 ] == 0.0 :
690
+ avg_color = np .average (colors , axis = 0 )
691
+ if avg_color [ - 1 ] == 0 :
692
+ # Skip fully-transparent triangles
691
693
return
692
694
693
695
trans_and_flip = self ._make_flip_transform (trans )
@@ -698,7 +700,7 @@ def draw_gouraud_triangle(self, gc, points, colors, trans):
698
700
x1 , y1 = tpoints [i ]
699
701
x2 , y2 = tpoints [(i + 1 ) % 3 ]
700
702
x3 , y3 = tpoints [(i + 2 ) % 3 ]
701
- c = colors [i ][: ]
703
+ rgba_color = colors [i ]
702
704
703
705
if x2 == x3 :
704
706
xb = x2
@@ -723,12 +725,13 @@ def draw_gouraud_triangle(self, gc, points, colors, trans):
723
725
writer .element (
724
726
'stop' ,
725
727
offset = '1' ,
726
- style = generate_css ({'stop-color' : rgb2hex (avg_color ),
727
- 'stop-opacity' : short_float_fmt (c [- 1 ])}))
728
+ style = generate_css ({
729
+ 'stop-color' : rgb2hex (avg_color ),
730
+ 'stop-opacity' : short_float_fmt (rgba_color [- 1 ])}))
728
731
writer .element (
729
732
'stop' ,
730
733
offset = '0' ,
731
- style = generate_css ({'stop-color' : rgb2hex (c ),
734
+ style = generate_css ({'stop-color' : rgb2hex (rgba_color ),
732
735
'stop-opacity' : "0" }))
733
736
734
737
writer .end ('linearGradient' )
0 commit comments