@@ -2715,6 +2715,46 @@ def get_affine(self):
2715
2715
return self ._transform .get_affine ()
2716
2716
2717
2717
2718
+ class TransformedPatchPath (TransformedPath ):
2719
+ """
2720
+ A :class:`TransformedPatchPath` caches a non-affine transformed copy of
2721
+ the :class:`~matplotlib.path.Patch`. This cached copy is automatically
2722
+ updated when the non-affine part of the transform or the patch changes.
2723
+ """
2724
+ def __init__ (self , patch ):
2725
+ """
2726
+ Create a new :class:`TransformedPatchPath` from the given
2727
+ :class:`~matplotlib.path.Patch`.
2728
+ """
2729
+ TransformNode .__init__ (self )
2730
+
2731
+ transform = patch .get_transform ()
2732
+ self ._patch = patch
2733
+ self ._transform = transform
2734
+ self .set_children (transform )
2735
+ self ._path = patch .get_path ()
2736
+ self ._transformed_path = None
2737
+ self ._transformed_points = None
2738
+
2739
+ def _revalidate (self ):
2740
+ patch_path = self ._patch .get_path ()
2741
+ # Only recompute if the invalidation includes the non_affine part of
2742
+ # the transform, or the Patch's Path has changed.
2743
+ if (self ._transformed_path is None or self ._path != patch_path or
2744
+ (self ._invalid & self .INVALID_NON_AFFINE ==
2745
+ self .INVALID_NON_AFFINE )):
2746
+ self ._path = patch_path
2747
+ self ._transformed_path = \
2748
+ self ._transform .transform_path_non_affine (patch_path )
2749
+ self ._transformed_points = \
2750
+ Path ._fast_from_codes_and_verts (
2751
+ self ._transform .transform_non_affine (patch_path .vertices ),
2752
+ None ,
2753
+ {'interpolation_steps' : patch_path ._interpolation_steps ,
2754
+ 'should_simplify' : patch_path .should_simplify })
2755
+ self ._invalid = 0
2756
+
2757
+
2718
2758
def nonsingular (vmin , vmax , expander = 0.001 , tiny = 1e-15 , increasing = True ):
2719
2759
'''
2720
2760
Modify the endpoints of a range as needed to avoid singularities.
0 commit comments