@@ -587,38 +587,26 @@ def contains_path(self, path, transform=None):
587
587
transform = transform .frozen ()
588
588
return _path .path_in_path (self , None , path , transform )
589
589
590
- def get_extents (self , transform = None ):
591
- """
592
- Return the extents (*xmin*, *ymin*, *xmax*, *ymax*) of the path.
593
-
594
- Unlike computing the extents on the *vertices* alone, this
595
- algorithm will take into account the curves and deal with
596
- control points appropriately.
597
- """
598
- from .transforms import Bbox
599
- path = self
600
- if transform is not None :
601
- transform = transform .frozen ()
602
- if not transform .is_affine :
603
- path = self .transformed (transform )
604
- transform = None
605
- return Bbox (_path .get_path_extents (path , transform ))
606
-
607
- def get_exact_extents (self , ** kwargs ):
590
+ def get_extents (self , transform = None , ** kwargs ):
608
591
"""Get size of Bbox of curve (instead of Bbox of control points).
609
592
610
593
Parameters
611
594
----------
595
+ transform : matplotlib.transforms.Transform, optional
596
+ Transform to apply to path before computing extents, if any.
612
597
kwargs : Dict[str, object]
613
598
Forwarded to self.iter_bezier.
614
599
615
600
Returns
616
601
-------
617
- extents : (4,) float, array_like
618
- The extents of the path ( xmin, ymin, xmax, ymax).
602
+ bbox : matplotlib.transforms.Bbox
603
+ The extents of the path Bbox([[ xmin, ymin], [ xmax, ymax]])
619
604
"""
605
+ from .transforms import Bbox
606
+ if transform is not None :
607
+ self = transform .transform_path (self )
620
608
maxi = 2 # [xmin, ymin, *xmax, ymax]
621
- # return value for empty paths to match _path.h
609
+ # return value for empty paths to match what used to be done in _path.h
622
610
extents = np .array ([np .inf , np .inf , - np .inf , - np .inf ])
623
611
for curve , code in self .iter_bezier (** kwargs ):
624
612
# start and endpoints can be extrema of the curve
@@ -628,10 +616,10 @@ def get_exact_extents(self, **kwargs):
628
616
_ , dzeros = curve .axis_aligned_extrema
629
617
if len (dzeros ) == 0 :
630
618
continue
631
- for zero in dzeros :
632
- potential_extrema = curve .point_at_t (zero )
619
+ for ti in dzeros :
620
+ potential_extrema = curve .point_at_t (ti )
633
621
_update_extents (extents , potential_extrema )
634
- return extents
622
+ return Bbox . from_extents ( extents )
635
623
636
624
def intersects_path (self , other , filled = True ):
637
625
"""
0 commit comments