Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9dc3840

Browse filesBrowse files
committed
more clear name: iter_bezier
1 parent d7084de commit 9dc3840
Copy full SHA for 9dc3840

File tree

Expand file treeCollapse file tree

1 file changed

+17
-18
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+17
-18
lines changed

‎lib/matplotlib/path.py

Copy file name to clipboardExpand all lines: lib/matplotlib/path.py
+17-18Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,10 @@ def iter_segments(self, transform=None, remove_nans=True, clip=None,
432432
curr_vertices = np.append(curr_vertices, next(vertices))
433433
yield curr_vertices, code
434434

435-
def iter_curves(self, **kwargs):
435+
def iter_bezier(self, **kwargs):
436436
"""
437437
Iterate over each bezier curve (lines included) in a Path.
438438
439-
This is in contrast to iter_segments, which omits the first control
440-
point of each curve.
441-
442439
Parameters
443440
----------
444441
kwargs : Dict[str, object]
@@ -455,30 +452,33 @@ def iter_curves(self, **kwargs):
455452
The code describing what kind of curve is being returned.
456453
Path.MOVETO, Path.LINETO, Path.CURVE3, Path.CURVE4 correspond to
457454
bezier curves with 1, 2, 3, and 4 control points (respectively).
455+
Path.CLOSEPOLY is a Path.LINETO with the control points correctly
456+
chosen based on the start/end points of the current stroke.
458457
"""
459-
first_vertex = None
460-
prev_vertex = None
458+
first_vert = None
459+
prev_vert = None
461460
for vertices, code in self.iter_segments(**kwargs):
462-
if first_vertex is None:
461+
if first_vert is None:
463462
if code != Path.MOVETO:
464463
raise ValueError("Malformed path, must start with MOVETO.")
465464
if code == Path.MOVETO: # a point is like "CURVE1"
466-
first_vertex = vertices
467-
yield np.array([first_vertex]), code
465+
first_vert = vertices
466+
yield BezierSegment(np.array([first_vert])), code
468467
elif code == Path.LINETO: # "CURVE2"
469-
yield np.array([prev_vertex, vertices]), code
468+
yield BezierSegment(np.array([prev_vert, vertices])), code
470469
elif code == Path.CURVE3:
471-
yield np.array([prev_vertex, vertices[:2], vertices[2:]]), code
470+
yield BezierSegment(np.array([prev_vert, vertices[:2],
471+
vertices[2:]])), code
472472
elif code == Path.CURVE4:
473-
yield np.array([prev_vertex, vertices[:2], vertices[2:4],
474-
vertices[4:]]), code
473+
yield BezierSegment(np.array([prev_vert, vertices[:2],
474+
vertices[2:4], vertices[4:]])), code
475475
elif code == Path.CLOSEPOLY:
476-
yield np.array([prev_vertex, first_vertex]), code
476+
yield BezierSegment(np.array([prev_vert, first_vert])), code
477477
elif code == Path.STOP:
478478
return
479479
else:
480480
raise ValueError("Invalid Path.code_type: " + str(code))
481-
prev_vertex = vertices[-2:]
481+
prev_vert = vertices[-2:]
482482

483483
@cbook._delete_parameter("3.3", "quantize")
484484
def cleaned(self, transform=None, remove_nans=False, clip=None,
@@ -611,7 +611,7 @@ def get_exact_extents(self, **kwargs):
611611
Parameters
612612
----------
613613
kwargs : Dict[str, object]
614-
Forwarded to self.iter_curves.
614+
Forwarded to self.iter_bezier.
615615
616616
Returns
617617
-------
@@ -621,8 +621,7 @@ def get_exact_extents(self, **kwargs):
621621
maxi = 2 # [xmin, ymin, *xmax, ymax]
622622
# return value for empty paths to match _path.h
623623
extents = np.array([np.inf, np.inf, -np.inf, -np.inf])
624-
for curve, code in self.iter_curves(**kwargs):
625-
curve = BezierSegment(curve)
624+
for curve, code in self.iter_bezier(**kwargs):
626625
# start and endpoints can be extrema of the curve
627626
_update_extents(extents, curve(0)) # start point
628627
_update_extents(extents, curve(1)) # end point

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.