From: <md...@us...> - 2007-12-10 16:26:05
|
Revision: 4691 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4691&view=rev Author: mdboom Date: 2007-12-10 08:26:00 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Somehow the merge went awry last time. Fixing. Modified Paths: -------------- branches/transforms/lib/matplotlib/backends/backend_cairo.py branches/transforms/lib/matplotlib/backends/backend_pdf.py branches/transforms/lib/matplotlib/backends/backend_ps.py branches/transforms/lib/matplotlib/backends/backend_svg.py Modified: branches/transforms/lib/matplotlib/backends/backend_cairo.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_cairo.py 2007-12-10 16:23:52 UTC (rev 4690) +++ branches/transforms/lib/matplotlib/backends/backend_cairo.py 2007-12-10 16:26:00 UTC (rev 4691) @@ -118,7 +118,6 @@ ctx.stroke() -<<<<<<< .working #@staticmethod def convert_path(ctx, tpath): for points, code in tpath.iter_segments(): @@ -135,48 +134,12 @@ elif code == Path.CLOSEPOLY: ctx.close_path() convert_path = staticmethod(convert_path) -======= - def draw_path(self, gc, rgbFace, path): - ctx = gc.ctx - ctx.new_path() ->>>>>>> .merge-right.r4686 -<<<<<<< .working def draw_path(self, gc, path, transform, rgbFace=None): if len(path.vertices) > 18980: raise ValueError("The Cairo backend can not draw paths longer than 18980 points.") -======= - while 1: - code, xp, yp = path.vertex() - yp = self.height - yp - - if code == agg.path_cmd_stop: - ctx.close_path() - break - elif code == agg.path_cmd_move_to: - ctx.move_to(xp, yp) - elif code == agg.path_cmd_line_to: - ctx.line_to(xp, yp) - elif code == agg.path_cmd_curve3: - _, xp1, yp1 = path.vertex() - yp1 = self.height - yp1 - ctx.curve_to(xp, yp, xp, yp, xp1, yp1) - elif code == agg.path_cmd_curve4: - _, xp1, yp1 = path.vertex() - yp1 = self.height - yp1 - _, xp2, yp2 = path.vertex() - yp2 = self.height - yp2 - ctx.curve_to(xp, yp, xp1, yp1, xp2, yp2) - elif code == agg.path_cmd_end_poly: - ctx.close_path() - self._fill_and_stroke(ctx, rgbFace) - - def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2, - rotation): - if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name()) ->>>>>>> .merge-right.r4686 ctx = gc.ctx transform = transform + \ Affine2D().scale(1.0, -1.0).translate(0, self.height) Modified: branches/transforms/lib/matplotlib/backends/backend_pdf.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-12-10 16:23:52 UTC (rev 4690) +++ branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-12-10 16:26:00 UTC (rev 4691) @@ -1211,97 +1211,7 @@ stat_key, (realpath, Set())) used_characters[1].update(set) -<<<<<<< .working def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None): -======= - def draw_arc(self, gcEdge, rgbFace, x, y, width, height, - angle1, angle2, rotation): - """ - Draw an arc using GraphicsContext instance gcEdge, centered at x,y, - with width and height and angles from 0.0 to 360.0 - 0 degrees is at 3-o'clock, rotated by `rotation` degrees - positive angles are anti-clockwise - - If the color rgbFace is not None, fill the arc with it. - """ - # source: agg_bezier_arc.cpp in agg23 - - def arc_to_bezier(cx, cy, rx, ry, angle1, sweep, rotation): - halfsweep = sweep / 2.0 - x0, y0 = cos(halfsweep), sin(halfsweep) - tx = (1.0 - x0) * 4.0/3.0; - ty = y0 - tx * x0 / y0; - px = x0, x0+tx, x0+tx, x0 - py = -y0, -ty, ty, y0 - sn, cs = sin(angle1 + halfsweep), cos(angle1 + halfsweep) - result = [ (rx * (pxi * cs - pyi * sn), - ry * (pxi * sn + pyi * cs)) - for pxi, pyi in zip(px, py) ] - result = [ (cx + cos(rotation)*x - sin(rotation)*y, - cy + sin(rotation)*x + cos(rotation)*y) - for x, y in result ] - return reduce(lambda x, y: x + y, result) - - epsilon = 0.01 - angle1 *= pi/180.0 - angle2 *= pi/180.0 - rotation *= pi/180.0 - sweep = angle2 - angle1 - angle1 = angle1 % (2*pi) - sweep = min(max(-2*pi, sweep), 2*pi) - - if sweep < 0.0: - sweep, angle1, angle2 = -sweep, angle2, angle1 - bp = [ pi/2.0 * i - for i in range(4) - if pi/2.0 * i < sweep-epsilon ] - bp.append(sweep) - subarcs = [ arc_to_bezier(x, y, width/2.0, height/2.0, - bp[i], bp[i+1]-bp[i], rotation) - for i in range(len(bp)-1) ] - - self.check_gc(gcEdge, rgbFace) - self.file.output(subarcs[0][0], subarcs[0][1], Op.moveto) - for arc in subarcs: - self.file.output(*(arc[2:] + (Op.curveto,))) - - self.file.output(self.gc.close_and_paint()) - - def draw_path(self, gc, rgbFace, path): - self.check_gc(gc, rgbFace) - - cmds = [] - - while 1: - code, xp, yp = path.vertex() - - if code == agg.path_cmd_stop: - cmds.append(Op.closepath) - break - elif code == agg.path_cmd_move_to: - cmds.extend([xp, yp, Op.moveto]) - elif code == agg.path_cmd_line_to: - cmds.extend([xp, yp, Op.lineto]) - elif code == agg.path_cmd_curve3: - cmds.extend([xp, yp]) - cmds.extend([xp, yp]) - cmds.extend(path.vertex()[1:]) - cmds.append(Op.curveto) - elif code == agg.path_cmd_curve4: - cmds.extend([xp, yp]) - cmds.extend(path.vertex()[1:]) - cmds.extend(path.vertex()[1:]) - cmds.append(Op.curveto) - elif code == agg.path_cmd_end_poly: - cmds.append(Op.closepath) - self.file.output(*cmds) - self.file.output(self.gc.paint()) - - def get_image_magnification(self): - return self.image_magnification - - def draw_image(self, x, y, im, bbox): ->>>>>>> .merge-right.r4686 #print >>sys.stderr, "draw_image called" # MGDTODO: Support clippath here Modified: branches/transforms/lib/matplotlib/backends/backend_ps.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-12-10 16:23:52 UTC (rev 4690) +++ branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-12-10 16:26:00 UTC (rev 4691) @@ -1430,31 +1430,4 @@ clip newpath } bind def""", -<<<<<<< .working -======= - # angle1 angle2 rx ry x y *ellipse* - - """/ellipse { - newpath - matrix currentmatrix 7 1 roll - translate - scale - 0 0 1 5 3 roll arc - setmatrix - closepath - } bind def""", - """/unitcircle { - newpath -0. -1. moveto -0.2652031 -1.0 0.519579870785 -0.894633691588 0.707106781187 -0.707106781187 curveto -0.894633691588 -0.519579870785 1.0 -0.2652031 1.0 0.0 curveto -1.0 0.2652031 0.894633691588 0.519579870785 0.707106781187 0.707106781187 curveto -0.519579870785 0.894633691588 0.2652031 1.0 0.0 1.0 curveto --0.2652031 1.0 -0.519579870785 0.894633691588 -0.707106781187 0.707106781187 curveto --0.894633691588 0.519579870785 -1.0 0.2652031 -1.0 0.0 curveto --1.0 -0.2652031 -0.894633691588 -0.519579870785 -0.707106781187 -0.707106781187 curveto --0.519579870785 -0.894633691588 -0.2652031 -1.0 0.0 -1.0 curveto -closepath - } bind def""", - ->>>>>>> .merge-right.r4679 ] Modified: branches/transforms/lib/matplotlib/backends/backend_svg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-10 16:23:52 UTC (rev 4690) +++ branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-10 16:26:00 UTC (rev 4691) @@ -140,49 +140,6 @@ def close_group(self, s): self._svgwriter.write('</g>\n') -<<<<<<< .working -======= - def draw_path(self, gc, rgbFace, path): - cmd = [] - - while 1: - code, xp, yp = path.vertex() - yp = self.height - yp - - if code == agg.path_cmd_stop: - cmd.append('z') # Hack, path_cmd_end_poly not found - break - elif code == agg.path_cmd_move_to: - cmd.append('M%g %g' % (xp, yp)) - elif code == agg.path_cmd_line_to: - cmd.append('L%g %g' % (xp, yp)) - elif code == agg.path_cmd_curve3: - verts = [xp, yp] - verts.extent(path.vertex()[1:]) - verts[-1] = self.height - verts[-1] - cmd.append('Q%g %g %g %g' % tuple(verts)) - elif code == agg.path_cmd_curve4: - verts = [xp, yp] - verts.extend(path.vertex()[1:]) - verts[-1] = self.height - verts[-1] - verts.extend(path.vertex()[1:]) - verts[-1] = self.height - verts[-1] - cmd.append('C%g %g %g %g %g %g'%tuple(verts)) - elif code == agg.path_cmd_end_poly: - cmd.append('z') - - path_data = "".join(cmd) - self._draw_svg_element("path", 'd="%s"' % path_data, gc, rgbFace) - - def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2, rotation): - """ - Ignores angles for now - """ - details = 'cx="%s" cy="%s" rx="%s" ry="%s" transform="rotate(%1.1f %s %s)"' % \ - (x, self.height-y, width/2.0, height/2.0, -rotation, x, self.height-y) - self._draw_svg_element('ellipse', details, gc, rgbFace) - ->>>>>>> .merge-right.r4686 def option_image_nocomposite(self): """ if svg.image_noscale is True, compositing multiple images into one is prohibited This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |