@@ -432,53 +432,52 @@ def iter_segments(self, transform=None, remove_nans=True, clip=None,
432
432
curr_vertices = np .append (curr_vertices , next (vertices ))
433
433
yield curr_vertices , code
434
434
435
- def iter_curves (self , ** kwargs ):
435
+ def iter_bezier (self , ** kwargs ):
436
436
"""
437
437
Iterate over each bezier curve (lines included) in a Path.
438
438
439
- This is in contrast to iter_segments, which omits the first control
440
- point of each curve.
441
-
442
439
Parameters
443
440
----------
444
441
kwargs : Dict[str, object]
445
442
Forwareded to iter_segments.
446
443
447
444
Yields
448
445
------
449
- vertices : float, (N, 2) array_like
450
- The N control points of the next 2-dimensional bezier curve making
451
- up self. Note in particular that freestanding points are bezier
452
- curves of order 0, and lines are bezier curves of order 1 (with two
453
- control points).
446
+ B : matplotlib.bezier.BezierSegment
447
+ The bezier curves that make up the current path. Note in particular
448
+ that freestanding points are bezier curves of order 0, and lines
449
+ are bezier curves of order 1 (with two control points).
454
450
code : Path.code_type
455
451
The code describing what kind of curve is being returned.
456
452
Path.MOVETO, Path.LINETO, Path.CURVE3, Path.CURVE4 correspond to
457
453
bezier curves with 1, 2, 3, and 4 control points (respectively).
454
+ Path.CLOSEPOLY is a Path.LINETO with the control points correctly
455
+ chosen based on the start/end points of the current stroke.
458
456
"""
459
- first_vertex = None
460
- prev_vertex = None
457
+ first_vert = None
458
+ prev_vert = None
461
459
for vertices , code in self .iter_segments (** kwargs ):
462
- if first_vertex is None :
460
+ if first_vert is None :
463
461
if code != Path .MOVETO :
464
462
raise ValueError ("Malformed path, must start with MOVETO." )
465
463
if code == Path .MOVETO : # a point is like "CURVE1"
466
- first_vertex = vertices
467
- yield np .array ([first_vertex ] ), code
464
+ first_vert = vertices
465
+ yield BezierSegment ( np .array ([first_vert ]) ), code
468
466
elif code == Path .LINETO : # "CURVE2"
469
- yield np .array ([prev_vertex , vertices ]), code
467
+ yield BezierSegment ( np .array ([prev_vert , vertices ]) ), code
470
468
elif code == Path .CURVE3 :
471
- yield np .array ([prev_vertex , vertices [:2 ], vertices [2 :]]), code
469
+ yield BezierSegment (np .array ([prev_vert , vertices [:2 ],
470
+ vertices [2 :]])), code
472
471
elif code == Path .CURVE4 :
473
- yield np .array ([prev_vertex , vertices [:2 ], vertices [ 2 : 4 ],
474
- vertices [4 :]]), code
472
+ yield BezierSegment ( np .array ([prev_vert , vertices [:2 ],
473
+ vertices [ 2 : 4 ], vertices [4 :]]) ), code
475
474
elif code == Path .CLOSEPOLY :
476
- yield np .array ([prev_vertex , first_vertex ] ), code
475
+ yield BezierSegment ( np .array ([prev_vert , first_vert ]) ), code
477
476
elif code == Path .STOP :
478
477
return
479
478
else :
480
479
raise ValueError ("Invalid Path.code_type: " + str (code ))
481
- prev_vertex = vertices [- 2 :]
480
+ prev_vert = vertices [- 2 :]
482
481
483
482
@cbook ._delete_parameter ("3.3" , "quantize" )
484
483
def cleaned (self , transform = None , remove_nans = False , clip = None ,
@@ -611,7 +610,7 @@ def get_exact_extents(self, **kwargs):
611
610
Parameters
612
611
----------
613
612
kwargs : Dict[str, object]
614
- Forwarded to self.iter_curves .
613
+ Forwarded to self.iter_bezier .
615
614
616
615
Returns
617
616
-------
@@ -621,8 +620,7 @@ def get_exact_extents(self, **kwargs):
621
620
maxi = 2 # [xmin, ymin, *xmax, ymax]
622
621
# return value for empty paths to match _path.h
623
622
extents = np .array ([np .inf , np .inf , - np .inf , - np .inf ])
624
- for curve , code in self .iter_curves (** kwargs ):
625
- curve = BezierSegment (curve )
623
+ for curve , code in self .iter_bezier (** kwargs ):
626
624
# start and endpoints can be extrema of the curve
627
625
_update_extents (extents , curve (0 )) # start point
628
626
_update_extents (extents , curve (1 )) # end point
0 commit comments