@@ -1132,40 +1132,44 @@ def convert_mesh_to_paths(meshWidth, meshHeight, coordinates):
11321132 def convert_mesh_to_triangles (self , meshWidth , meshHeight , coordinates ):
11331133 """
11341134 Converts a given mesh into a sequence of triangles, each point
1135- with its own color
1136- :class:`matplotlib.path.Path` objects for easier rendering by
1137- backends that do not directly support quadmeshes.
1138-
1139- This function is primarily of use to backend implementers.
1135+ with its own color. This is useful for experiments using
1136+ `draw_qouraud_triangle`.
11401137 """
11411138 Path = mpath .Path
11421139
11431140 if ma .isMaskedArray (coordinates ):
1144- c = coordinates .data
1141+ p = coordinates .data
11451142 else :
1146- c = coordinates
1143+ p = coordinates
1144+
1145+ p_a = p [0 :- 1 , 0 :- 1 ]
1146+ p_b = p [0 :- 1 , 1 : ]
1147+ p_c = p [1 : , 1 : ]
1148+ p_d = p [1 : , 0 :- 1 ]
1149+ p_center = (p_a + p_b + p_c + p_d ) / 4.0
11471150
11481151 triangles = np .concatenate ((
1149- c [0 :- 1 , 0 :- 1 ],
1150- c [0 :- 1 , 1 : ],
1151- c [1 : , 1 : ],
1152- c [1 : , 1 : ],
1153- c [1 : , 0 :- 1 ],
1154- c [0 :- 1 , 0 :- 1 ]
1152+ p_a , p_b , p_center ,
1153+ p_b , p_c , p_center ,
1154+ p_c , p_d , p_center ,
1155+ p_d , p_a , p_center ,
11551156 ), axis = 2 )
1156- triangles = triangles .reshape ((meshWidth * meshHeight * 2 , 3 , 2 ))
1157+ triangles = triangles .reshape ((meshWidth * meshHeight * 4 , 3 , 2 ))
11571158
11581159 c = self .get_facecolor ().reshape ((meshHeight + 1 , meshWidth + 1 , 4 ))
1160+ c_a = c [0 :- 1 , 0 :- 1 ]
1161+ c_b = c [0 :- 1 , 1 : ]
1162+ c_c = c [1 : , 1 : ]
1163+ c_d = c [1 : , 0 :- 1 ]
1164+ c_center = (c_a + c_b + c_c + c_d ) / 4.0
1165+
11591166 colors = np .concatenate ((
1160- c [0 :- 1 , 0 :- 1 ],
1161- c [0 :- 1 , 1 : ],
1162- c [1 : , 1 : ],
1163- c [1 : , 1 : ],
1164- c [1 : , 0 :- 1 ],
1165- c [0 :- 1 , 0 :- 1 ]
1167+ c_a , c_b , c_center ,
1168+ c_b , c_c , c_center ,
1169+ c_c , c_d , c_center ,
1170+ c_d , c_a , c_center ,
11661171 ), axis = 2 )
1167-
1168- colors = colors .reshape ((meshWidth * meshHeight * 2 , 3 , 4 ))
1172+ colors = colors .reshape ((meshWidth * meshHeight * 4 , 3 , 4 ))
11691173
11701174 return triangles , colors
11711175
0 commit comments