@@ -588,13 +588,19 @@ def get_extents(self, transform=None, **kwargs):
588
588
from .transforms import Bbox
589
589
if transform is not None :
590
590
self = transform .transform_path (self )
591
- bbox = Bbox .null ()
592
- for curve , code in self .iter_bezier (** kwargs ):
593
- # places where the derivative is zero can be extrema
594
- _ , dzeros = curve .axis_aligned_extrema ()
595
- # as can the ends of the curve
596
- bbox .update_from_data_xy (curve ([0 , * dzeros , 1 ]), ignore = False )
597
- return bbox
591
+ if self .codes is None :
592
+ xys = self .vertices
593
+ elif len (np .intersect1d (self .codes , [Path .CURVE3 , Path .CURVE4 ])) == 0 :
594
+ xys = self .vertices [self .codes != Path .CLOSEPOLY ]
595
+ else :
596
+ xys = []
597
+ for curve , code in self .iter_bezier (** kwargs ):
598
+ # places where the derivative is zero can be extrema
599
+ _ , dzeros = curve .axis_aligned_extrema ()
600
+ # as can the ends of the curve
601
+ xys .append (curve ([0 , * dzeros , 1 ]))
602
+ xys = np .concatenate (xys )
603
+ return Bbox ([xys .min (axis = 0 ), xys .max (axis = 0 )])
598
604
599
605
def intersects_path (self , other , filled = True ):
600
606
"""
0 commit comments