Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ae4a308

Browse files
committed
Merge pull request #684 from mdboom/initial-moveto
Fix 'Path lacks initial MOVETO'
2 parents 7f3bac3 + d41a7c0 commit ae4a308

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

lib/matplotlib/backends/backend_cairo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ def convert_path(ctx, path, transform):
127127
for points, code in path.iter_segments(transform):
128128
if code == Path.MOVETO:
129129
ctx.move_to(*points)
130+
elif code == Path.CLOSEPOLY:
131+
ctx.close_path()
130132
elif code == Path.LINETO:
131133
ctx.line_to(*points)
132134
elif code == Path.CURVE3:
@@ -135,8 +137,6 @@ def convert_path(ctx, path, transform):
135137
points[2], points[3])
136138
elif code == Path.CURVE4:
137139
ctx.curve_to(*points)
138-
elif code == Path.CLOSEPOLY:
139-
ctx.close_path()
140140

141141

142142
def draw_path(self, gc, path, transform, rgbFace=None):

lib/matplotlib/backends/backend_emf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,15 @@ def convert_path(self, tpath):
234234
for points, code in tpath.iter_segments():
235235
if code == Path.MOVETO:
236236
self.emf.MoveTo(*points)
237+
elif code == Path.CLOSEPOLY:
238+
self.emf.CloseFigure()
237239
elif code == Path.LINETO:
238240
self.emf.LineTo(*points)
239241
elif code == Path.CURVE3:
240242
points = quad2cubic(*(list(last_points[-2:]) + list(points)))
241243
self.emf.PolyBezierTo(zip(points[2::2], points[3::2]))
242244
elif code == Path.CURVE4:
243245
self.emf.PolyBezierTo(zip(points[::2], points[1::2]))
244-
elif code == Path.CLOSEPOLY:
245-
self.emf.CloseFigure()
246246
last_points = points
247247
self.emf.EndPath()
248248

lib/matplotlib/backends/backend_pdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,8 @@ def pathOperations(path, transform, clip=None, simplify=None):
12271227
# This is allowed anywhere in the path
12281228
cmds.extend(points)
12291229
cmds.append(Op.moveto)
1230+
elif code == Path.CLOSEPOLY:
1231+
cmds.append(Op.closepath)
12301232
elif last_points is None:
12311233
# The other operations require a previous point
12321234
raise ValueError, 'Path lacks initial MOVETO'
@@ -1240,8 +1242,6 @@ def pathOperations(path, transform, clip=None, simplify=None):
12401242
elif code == Path.CURVE4:
12411243
cmds.extend(points)
12421244
cmds.append(Op.curveto)
1243-
elif code == Path.CLOSEPOLY:
1244-
cmds.append(Op.closepath)
12451245
last_points = points
12461246
return cmds
12471247

lib/matplotlib/backends/backend_ps.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,11 @@ def _convert_path(self, path, transform, clip=False, simplify=None):
524524
simplify=simplify):
525525
if code == Path.MOVETO:
526526
ps.append("%g %g m" % tuple(points))
527+
elif code == Path.CLOSEPOLY:
528+
ps.append("cl")
529+
elif last_points is None:
530+
# The other operations require a previous point
531+
raise ValueError('Path lacks initial MOVETO')
527532
elif code == Path.LINETO:
528533
ps.append("%g %g l" % tuple(points))
529534
elif code == Path.CURVE3:
@@ -532,8 +537,6 @@ def _convert_path(self, path, transform, clip=False, simplify=None):
532537
tuple(points[2:]))
533538
elif code == Path.CURVE4:
534539
ps.append("%g %g %g %g %g %g c" % tuple(points))
535-
elif code == Path.CLOSEPOLY:
536-
ps.append("cl")
537540
last_points = points
538541

539542
ps = "\n".join(ps)

0 commit comments

Comments
 (0)