From: <md...@us...> - 2009-08-12 19:17:19
|
Revision: 7478 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7478&view=rev Author: mdboom Date: 2009-08-12 19:17:09 +0000 (Wed, 12 Aug 2009) Log Message: ----------- New version of Gouraud quadmesh shader with 4 triangles per quad. Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py trunk/matplotlib/lib/matplotlib/collections.py trunk/matplotlib/src/_backend_agg.cpp Modified: trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py 2009-08-12 16:53:41 UTC (rev 7477) +++ trunk/matplotlib/examples/pylab_examples/quadmesh_demo.py 2009-08-12 19:17:09 UTC (rev 7478) @@ -38,7 +38,7 @@ #cmap.set_bad('r', 1.0) #ax.pcolormesh(Qx,Qz,Zm, cmap=cmap) # Or use the default, which is transparent: -col = ax.pcolormesh(Qx,Qz,Zm) +col = ax.pcolormesh(Qx,Qz,Zm,shading='gouraud') ax.set_title('With masked values') Modified: trunk/matplotlib/lib/matplotlib/collections.py =================================================================== --- trunk/matplotlib/lib/matplotlib/collections.py 2009-08-12 16:53:41 UTC (rev 7477) +++ trunk/matplotlib/lib/matplotlib/collections.py 2009-08-12 19:17:09 UTC (rev 7478) @@ -1132,41 +1132,45 @@ def convert_mesh_to_triangles(self, meshWidth, meshHeight, coordinates): """ Converts a given mesh into a sequence of triangles, each point - with its own color - :class:`matplotlib.path.Path` objects for easier rendering by - backends that do not directly support quadmeshes. - - This function is primarily of use to backend implementers. + with its own color. This is useful for experiments using + `draw_qouraud_triangle`. """ Path = mpath.Path if ma.isMaskedArray(coordinates): - c = coordinates.data + p = coordinates.data else: - c = coordinates + p = coordinates + p_a = p[0:-1, 0:-1] + p_b = p[0:-1, 1: ] + p_c = p[1: , 1: ] + p_d = p[1: , 0:-1] + p_center = (p_a + p_b + p_c + p_d) / 4.0 + triangles = np.concatenate(( - c[0:-1, 0:-1], - c[0:-1, 1: ], - c[1: , 1: ], - c[1: , 1: ], - c[1: , 0:-1], - c[0:-1, 0:-1] + p_a, p_b, p_center, + p_b, p_c, p_center, + p_c, p_d, p_center, + p_d, p_a, p_center, ), axis=2) - triangles = triangles.reshape((meshWidth * meshHeight * 2, 3, 2)) + triangles = triangles.reshape((meshWidth * meshHeight * 4, 3, 2)) c = self.get_facecolor().reshape((meshHeight + 1, meshWidth + 1, 4)) + c_a = c[0:-1, 0:-1] + c_b = c[0:-1, 1: ] + c_c = c[1: , 1: ] + c_d = c[1: , 0:-1] + c_center = (c_a + c_b + c_c + c_d) / 4.0 + colors = np.concatenate(( - c[0:-1, 0:-1], - c[0:-1, 1: ], - c[1: , 1: ], - c[1: , 1: ], - c[1: , 0:-1], - c[0:-1, 0:-1] + c_a, c_b, c_center, + c_b, c_c, c_center, + c_c, c_d, c_center, + c_d, c_a, c_center, ), axis=2) + colors = colors.reshape((meshWidth * meshHeight * 4, 3, 4)) - colors = colors.reshape((meshWidth * meshHeight * 2, 3, 4)) - return triangles, colors def get_datalim(self, transData): Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2009-08-12 16:53:41 UTC (rev 7477) +++ trunk/matplotlib/src/_backend_agg.cpp 2009-08-12 19:17:09 UTC (rev 7478) @@ -1470,6 +1470,10 @@ Py::Object colors_obj = args[2]; agg::trans_affine trans = py_to_agg_transformation_matrix(args[3].ptr()); + theRasterizer.reset_clipping(); + rendererBase.reset_clipping(true); + set_clipbox(gc.cliprect, theRasterizer); + trans *= agg::trans_affine_scaling(1.0, -1.0); trans *= agg::trans_affine_translation(0.0, (double)height); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |