Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit9dc3840

Browse files
committed
more clear name:iter_bezier
1 parentd7084de commit9dc3840

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

‎lib/matplotlib/path.py

Lines 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
yieldcurr_vertices,code
434434

435-
defiter_curves(self,**kwargs):
435+
defiter_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
forvertices,codeinself.iter_segments(**kwargs):
462-
iffirst_vertexisNone:
461+
iffirst_vertisNone:
463462
ifcode!=Path.MOVETO:
464463
raiseValueError("Malformed path, must start with MOVETO.")
465464
ifcode==Path.MOVETO:# a point is like "CURVE1"
466-
first_vertex=vertices
467-
yieldnp.array([first_vertex]),code
465+
first_vert=vertices
466+
yieldBezierSegment(np.array([first_vert])),code
468467
elifcode==Path.LINETO:# "CURVE2"
469-
yieldnp.array([prev_vertex,vertices]),code
468+
yieldBezierSegment(np.array([prev_vert,vertices])),code
470469
elifcode==Path.CURVE3:
471-
yieldnp.array([prev_vertex,vertices[:2],vertices[2:]]),code
470+
yieldBezierSegment(np.array([prev_vert,vertices[:2],
471+
vertices[2:]])),code
472472
elifcode==Path.CURVE4:
473-
yieldnp.array([prev_vertex,vertices[:2],vertices[2:4],
474-
vertices[4:]]),code
473+
yieldBezierSegment(np.array([prev_vert,vertices[:2],
474+
vertices[2:4],vertices[4:]])),code
475475
elifcode==Path.CLOSEPOLY:
476-
yieldnp.array([prev_vertex,first_vertex]),code
476+
yieldBezierSegment(np.array([prev_vert,first_vert])),code
477477
elifcode==Path.STOP:
478478
return
479479
else:
480480
raiseValueError("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
defcleaned(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-
forcurve,codeinself.iter_curves(**kwargs):
625-
curve=BezierSegment(curve)
624+
forcurve,codeinself.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)

[8]ページ先頭

©2009-2025 Movatter.jp