def _convert_path(self, path, transform, clip=False, simplify=None): ps = [] last_points = None if clip: clip = (0.0, 0.0, self.width * 72.0, self.height * 72.0) else: clip = None for points, code in path.iter_segments(transform, clip=clip, simplify=simplify): if code == Path.MOVETO: ps.append("%g %g m" % tuple(points)) elif code == Path.LINETO: ps.append("%g %g l" % tuple(points)) elif code == Path.CURVE3: points = quad2cubic(*(list(last_points[-2:]) + list(points))) ps.append("%g %g %g %g %g %g c" % tuple(points[2:])) elif code == Path.CURVE4: ps.append("%g %g %g %g %g %g c" % tuple(points)) elif code == Path.CLOSEPOLY: ps.append("cl") last_points = points ps = "\n".join(ps) return ps
def quad2cubic(q0x, q0y, q1x, q1y, q2x, q2y): """ This function has been moved to matplotlib.mlab -- please import it from there """ warnings.warn('quad2cubic has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) import matplotlib.mlab as mlab return mlab.quad2cubic(q0x, q0y, q1x, q1y, q2x, q2y)
def quad2cubic(q0x, q0y, q1x, q1y, q2x, q2y): """ This function has been moved to matplotlib.mlab -- please import it from there """ # deprecated from cbook in 0.98.4 warnings.warn('quad2cubic has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) import matplotlib.mlab as mlab return mlab.quad2cubic(q0x, q0y, q1x, q1y, q2x, q2y)
def convert_path(self, tpath): self.emf.BeginPath() last_points = None for points, code in tpath.iter_segments(): if code == Path.MOVETO: self.emf.MoveTo(*points) elif code == Path.CLOSEPOLY: self.emf.CloseFigure() elif code == Path.LINETO: self.emf.LineTo(*points) elif code == Path.CURVE3: points = quad2cubic(*(list(last_points[-2:]) + list(points))) self.emf.PolyBezierTo(list(zip(points[2::2], points[3::2]))) elif code == Path.CURVE4: self.emf.PolyBezierTo(list(zip(points[::2], points[1::2]))) last_points = points self.emf.EndPath()
def convert_path(self, tpath): self.emf.BeginPath() last_points = None for points, code in tpath.iter_segments(): if code == Path.MOVETO: self.emf.MoveTo(*points) elif code == Path.LINETO: self.emf.LineTo(*points) elif code == Path.CURVE3: points = quad2cubic(*(list(last_points[-2:]) + list(points))) self.emf.PolyBezierTo(zip(points[2::2], points[3::2])) elif code == Path.CURVE4: self.emf.PolyBezierTo(zip(points[::2], points[1::2])) elif code == Path.CLOSEPOLY: self.emf.CloseFigure() last_points = points self.emf.EndPath()
def _convert_path(self, path, transform, simplify=None): path = transform.transform_path(path) ps = [] last_points = None for points, code in path.iter_segments(simplify): if code == Path.MOVETO: ps.append("%g %g m" % tuple(points)) elif code == Path.LINETO: ps.append("%g %g l" % tuple(points)) elif code == Path.CURVE3: points = quad2cubic(*(list(last_points[-2:]) + list(points))) ps.append("%g %g %g %g %g %g c" % tuple(points[2:])) elif code == Path.CURVE4: ps.append("%g %g %g %g %g %g c" % tuple(points)) elif code == Path.CLOSEPOLY: ps.append("cl") last_points = points ps = "\n".join(ps) return ps