77import math
88from numbers import Number
99import textwrap
10+ from types import SimpleNamespace
1011from collections import namedtuple
1112
1213import numpy as np
@@ -2698,59 +2699,35 @@ class _Base:
26982699 helper methods.
26992700 """
27002701
2702+ @_api .deprecated ("3.7" )
27012703 class SimpleEvent :
27022704 def __init__ (self , xy ):
27032705 self .x , self .y = xy
27042706
2705- def _clip (self , path , patchA , patchB ):
2707+ def _in_patch (self , patch ):
27062708 """
2707- Clip the path to the boundary of the patchA and patchB.
2708- The starting point of the path needed to be inside of the
2709- patchA and the end point inside the patch B. The *contains*
2710- methods of each patch object is utilized to test if the point
2711- is inside the path.
2709+ Return a predicate function testing whether a point *xy* is
2710+ contained in *patch*.
27122711 """
2712+ return lambda xy : patch .contains (
2713+ SimpleNamespace (x = xy [0 ], y = xy [1 ]))[0 ]
27132714
2714- if patchA :
2715- def insideA (xy_display ):
2716- xy_event = ConnectionStyle ._Base .SimpleEvent (xy_display )
2717- return patchA .contains (xy_event )[0 ]
2718-
2719- try :
2720- left , right = split_path_inout (path , insideA )
2721- except ValueError :
2722- right = path
2723-
2724- path = right
2725-
2726- if patchB :
2727- def insideB (xy_display ):
2728- xy_event = ConnectionStyle ._Base .SimpleEvent (xy_display )
2729- return patchB .contains (xy_event )[0 ]
2730-
2731- try :
2732- left , right = split_path_inout (path , insideB )
2733- except ValueError :
2734- left = path
2735-
2736- path = left
2737-
2738- return path
2739-
2740- def _shrink (self , path , shrinkA , shrinkB ):
2715+ def _clip (self , path , in_start , in_stop ):
27412716 """
2742- Shrink the path by fixed size (in points) with shrinkA and shrinkB.
2717+ Clip *path* at its start by the region where *in_start* returns
2718+ True, and at its stop by the region where *in_stop* returns True.
2719+
2720+ The original path is assumed to start in the *in_start* region and
2721+ to stop in the *in_stop* region.
27432722 """
2744- if shrinkA :
2745- insideA = inside_circle (* path .vertices [0 ], shrinkA )
2723+ if in_start :
27462724 try :
2747- left , path = split_path_inout (path , insideA )
2725+ _ , path = split_path_inout (path , in_start )
27482726 except ValueError :
27492727 pass
2750- if shrinkB :
2751- insideB = inside_circle (* path .vertices [- 1 ], shrinkB )
2728+ if in_stop :
27522729 try :
2753- path , right = split_path_inout (path , insideB )
2730+ path , _ = split_path_inout (path , in_stop )
27542731 except ValueError :
27552732 pass
27562733 return path
@@ -2762,9 +2739,17 @@ def __call__(self, posA, posB,
27622739 *posB*; then clip and shrink the path.
27632740 """
27642741 path = self .connect (posA , posB )
2765- clipped_path = self ._clip (path , patchA , patchB )
2766- shrunk_path = self ._shrink (clipped_path , shrinkA , shrinkB )
2767- return shrunk_path
2742+ path = self ._clip (
2743+ path ,
2744+ self ._in_patch (patchA ) if patchA else None ,
2745+ self ._in_patch (patchB ) if patchB else None ,
2746+ )
2747+ path = self ._clip (
2748+ path ,
2749+ inside_circle (* path .vertices [0 ], shrinkA ) if shrinkA else None ,
2750+ inside_circle (* path .vertices [- 1 ], shrinkB ) if shrinkB else None
2751+ )
2752+ return path
27682753
27692754 @_register_style (_style_list )
27702755 class Arc3 (_Base ):
0 commit comments