1010import matplotlib as mpl
1111from . import artist , cbook , colors , docstring , lines as mlines , transforms
1212from .bezier import (
13- NonIntersectingPathException , get_cos_sin , get_intersection ,
14- get_parallels , inside_circle , make_wedged_bezier2 ,
15- split_bezier_intersecting_with_closedpath , split_path_inout )
13+ NonIntersectingPathException , get_cos_sin , get_intersection , get_parallels ,
14+ make_wedged_bezier2 , split_bezier_intersecting_with_closedpath )
1615from .path import Path
1716
1817
18+ def _inside_circle (cx , cy , r ):
19+ """
20+ Return a function that checks whether a point is in a circle with center
21+ (*cx*, *cy*) and radius *r*.
22+
23+ The returned function has the signature::
24+
25+ f(xy: Tuple[float, float]) -> bool
26+ """
27+ r2 = r ** 2
28+
29+ def _f (xy ):
30+ x , y = xy
31+ return (x - cx ) ** 2 + (y - cy ) ** 2 < r2
32+ return _f
33+
34+
1935@cbook ._define_aliases ({
2036 "antialiased" : ["aa" ],
2137 "edgecolor" : ["ec" ],
@@ -2411,7 +2427,7 @@ def insideA(xy_display):
24112427 return patchA .contains (xy_event )[0 ]
24122428
24132429 try :
2414- left , right = split_path_inout (path , insideA )
2430+ left , right = path . split_path_inout (insideA )
24152431 except ValueError :
24162432 right = path
24172433
@@ -2423,7 +2439,7 @@ def insideB(xy_display):
24232439 return patchB .contains (xy_event )[0 ]
24242440
24252441 try :
2426- left , right = split_path_inout (path , insideB )
2442+ left , right = path . split_path_inout (insideB )
24272443 except ValueError :
24282444 left = path
24292445
@@ -2436,15 +2452,15 @@ def _shrink(self, path, shrinkA, shrinkB):
24362452 Shrink the path by fixed size (in points) with shrinkA and shrinkB.
24372453 """
24382454 if shrinkA :
2439- insideA = inside_circle (* path .vertices [0 ], shrinkA )
2455+ insideA = _inside_circle (* path .vertices [0 ], shrinkA )
24402456 try :
2441- left , path = split_path_inout (path , insideA )
2457+ left , path = path . split_path_inout (insideA )
24422458 except ValueError :
24432459 pass
24442460 if shrinkB :
2445- insideB = inside_circle (* path .vertices [- 1 ], shrinkB )
2461+ insideB = _inside_circle (* path .vertices [- 1 ], shrinkB )
24462462 try :
2447- path , right = split_path_inout (path , insideB )
2463+ path , right = path . split_path_inout (insideB )
24482464 except ValueError :
24492465 pass
24502466 return path
@@ -2869,7 +2885,6 @@ def __call__(self, path, mutation_size, linewidth,
28692885 The __call__ method is a thin wrapper around the transmute method
28702886 and takes care of the aspect ratio.
28712887 """
2872-
28732888 if aspect_ratio is not None :
28742889 # Squeeze the given height by the aspect_ratio
28752890 vertices = path .vertices / [1 , aspect_ratio ]
@@ -3334,7 +3349,7 @@ def transmute(self, path, mutation_size, linewidth):
33343349
33353350 # divide the path into a head and a tail
33363351 head_length = self .head_length * mutation_size
3337- in_f = inside_circle (x2 , y2 , head_length )
3352+ in_f = _inside_circle (x2 , y2 , head_length )
33383353 arrow_path = [(x0 , y0 ), (x1 , y1 ), (x2 , y2 )]
33393354
33403355 try :
@@ -3417,7 +3432,7 @@ def transmute(self, path, mutation_size, linewidth):
34173432 arrow_path = [(x0 , y0 ), (x1 , y1 ), (x2 , y2 )]
34183433
34193434 # path for head
3420- in_f = inside_circle (x2 , y2 , head_length )
3435+ in_f = _inside_circle (x2 , y2 , head_length )
34213436 try :
34223437 path_out , path_in = split_bezier_intersecting_with_closedpath (
34233438 arrow_path , in_f , tolerance = 0.01 )
@@ -3432,7 +3447,7 @@ def transmute(self, path, mutation_size, linewidth):
34323447 path_head = path_in
34333448
34343449 # path for head
3435- in_f = inside_circle (x2 , y2 , head_length * .8 )
3450+ in_f = _inside_circle (x2 , y2 , head_length * .8 )
34363451 path_out , path_in = split_bezier_intersecting_with_closedpath (
34373452 arrow_path , in_f , tolerance = 0.01 )
34383453 path_tail = path_out
@@ -3450,7 +3465,7 @@ def transmute(self, path, mutation_size, linewidth):
34503465 w1 = 1. , wm = 0.6 , w2 = 0.3 )
34513466
34523467 # path for head
3453- in_f = inside_circle (x0 , y0 , tail_width * .3 )
3468+ in_f = _inside_circle (x0 , y0 , tail_width * .3 )
34543469 path_in , path_out = split_bezier_intersecting_with_closedpath (
34553470 arrow_path , in_f , tolerance = 0.01 )
34563471 tail_start = path_in [- 1 ]
0 commit comments