@@ -2700,59 +2700,35 @@ class _Base:
2700
2700
helper methods.
2701
2701
"""
2702
2702
2703
+ @_api .deprecated ("3.7" )
2703
2704
class SimpleEvent :
2704
2705
def __init__ (self , xy ):
2705
2706
self .x , self .y = xy
2706
2707
2707
- def _clip (self , path , patchA , patchB ):
2708
+ def _in_patch (self , patch ):
2708
2709
"""
2709
- Clip the path to the boundary of the patchA and patchB.
2710
- The starting point of the path needed to be inside of the
2711
- patchA and the end point inside the patch B. The *contains*
2712
- methods of each patch object is utilized to test if the point
2713
- is inside the path.
2710
+ Return a predicate function testing whether a point *xy* is
2711
+ contained in *patch*.
2714
2712
"""
2713
+ return lambda xy : patch .contains (
2714
+ SimpleNamespace (x = xy [0 ], y = xy [1 ]))[0 ]
2715
2715
2716
- if patchA :
2717
- def insideA (xy_display ):
2718
- xy_event = ConnectionStyle ._Base .SimpleEvent (xy_display )
2719
- return patchA .contains (xy_event )[0 ]
2720
-
2721
- try :
2722
- left , right = split_path_inout (path , insideA )
2723
- except ValueError :
2724
- right = path
2725
-
2726
- path = right
2727
-
2728
- if patchB :
2729
- def insideB (xy_display ):
2730
- xy_event = ConnectionStyle ._Base .SimpleEvent (xy_display )
2731
- return patchB .contains (xy_event )[0 ]
2732
-
2733
- try :
2734
- left , right = split_path_inout (path , insideB )
2735
- except ValueError :
2736
- left = path
2737
-
2738
- path = left
2739
-
2740
- return path
2741
-
2742
- def _shrink (self , path , shrinkA , shrinkB ):
2716
+ def _clip (self , path , in_start , in_stop ):
2743
2717
"""
2744
- Shrink the path by fixed size (in points) with shrinkA and shrinkB.
2718
+ Clip *path* at its start by the region where *in_start* returns
2719
+ True, and at its stop by the region where *in_stop* returns True.
2720
+
2721
+ The original path is assumed to start in the *in_start* region and
2722
+ to stop in the *in_stop* region.
2745
2723
"""
2746
- if shrinkA :
2747
- insideA = inside_circle (* path .vertices [0 ], shrinkA )
2724
+ if in_start :
2748
2725
try :
2749
- left , path = split_path_inout (path , insideA )
2726
+ _ , path = split_path_inout (path , in_start )
2750
2727
except ValueError :
2751
2728
pass
2752
- if shrinkB :
2753
- insideB = inside_circle (* path .vertices [- 1 ], shrinkB )
2729
+ if in_stop :
2754
2730
try :
2755
- path , right = split_path_inout (path , insideB )
2731
+ path , _ = split_path_inout (path , in_stop )
2756
2732
except ValueError :
2757
2733
pass
2758
2734
return path
@@ -2764,9 +2740,17 @@ def __call__(self, posA, posB,
2764
2740
*posB*; then clip and shrink the path.
2765
2741
"""
2766
2742
path = self .connect (posA , posB )
2767
- clipped_path = self ._clip (path , patchA , patchB )
2768
- shrunk_path = self ._shrink (clipped_path , shrinkA , shrinkB )
2769
- return shrunk_path
2743
+ path = self ._clip (
2744
+ path ,
2745
+ self ._in_patch (patchA ) if patchA else None ,
2746
+ self ._in_patch (patchB ) if patchB else None ,
2747
+ )
2748
+ path = self ._clip (
2749
+ path ,
2750
+ inside_circle (* path .vertices [0 ], shrinkA ) if shrinkA else None ,
2751
+ inside_circle (* path .vertices [- 1 ], shrinkB ) if shrinkB else None
2752
+ )
2753
+ return path
2770
2754
2771
2755
@_register_style (_style_list )
2772
2756
class Arc3 (_Base ):
0 commit comments