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" ],
@@ -2428,7 +2444,7 @@ def insideA(xy_display):
24282444 return patchA .contains (xy_event )[0 ]
24292445
24302446 try :
2431- left , right = split_path_inout (path , insideA )
2447+ left , right = path . split_path_inout (insideA )
24322448 except ValueError :
24332449 right = path
24342450
@@ -2440,7 +2456,7 @@ def insideB(xy_display):
24402456 return patchB .contains (xy_event )[0 ]
24412457
24422458 try :
2443- left , right = split_path_inout (path , insideB )
2459+ left , right = path . split_path_inout (insideB )
24442460 except ValueError :
24452461 left = path
24462462
@@ -2453,15 +2469,15 @@ def _shrink(self, path, shrinkA, shrinkB):
24532469 Shrink the path by fixed size (in points) with shrinkA and shrinkB.
24542470 """
24552471 if shrinkA :
2456- insideA = inside_circle (* path .vertices [0 ], shrinkA )
2472+ insideA = _inside_circle (* path .vertices [0 ], shrinkA )
24572473 try :
2458- left , path = split_path_inout (path , insideA )
2474+ left , path = path . split_path_inout (insideA )
24592475 except ValueError :
24602476 pass
24612477 if shrinkB :
2462- insideB = inside_circle (* path .vertices [- 1 ], shrinkB )
2478+ insideB = _inside_circle (* path .vertices [- 1 ], shrinkB )
24632479 try :
2464- path , right = split_path_inout (path , insideB )
2480+ path , right = path . split_path_inout (insideB )
24652481 except ValueError :
24662482 pass
24672483 return path
@@ -2886,7 +2902,6 @@ def __call__(self, path, mutation_size, linewidth,
28862902 The __call__ method is a thin wrapper around the transmute method
28872903 and takes care of the aspect ratio.
28882904 """
2889-
28902905 if aspect_ratio is not None :
28912906 # Squeeze the given height by the aspect_ratio
28922907 vertices = path .vertices / [1 , aspect_ratio ]
@@ -3351,7 +3366,7 @@ def transmute(self, path, mutation_size, linewidth):
33513366
33523367 # divide the path into a head and a tail
33533368 head_length = self .head_length * mutation_size
3354- in_f = inside_circle (x2 , y2 , head_length )
3369+ in_f = _inside_circle (x2 , y2 , head_length )
33553370 arrow_path = [(x0 , y0 ), (x1 , y1 ), (x2 , y2 )]
33563371
33573372 try :
@@ -3434,7 +3449,7 @@ def transmute(self, path, mutation_size, linewidth):
34343449 arrow_path = [(x0 , y0 ), (x1 , y1 ), (x2 , y2 )]
34353450
34363451 # path for head
3437- in_f = inside_circle (x2 , y2 , head_length )
3452+ in_f = _inside_circle (x2 , y2 , head_length )
34383453 try :
34393454 path_out , path_in = split_bezier_intersecting_with_closedpath (
34403455 arrow_path , in_f , tolerance = 0.01 )
@@ -3449,7 +3464,7 @@ def transmute(self, path, mutation_size, linewidth):
34493464 path_head = path_in
34503465
34513466 # path for head
3452- in_f = inside_circle (x2 , y2 , head_length * .8 )
3467+ in_f = _inside_circle (x2 , y2 , head_length * .8 )
34533468 path_out , path_in = split_bezier_intersecting_with_closedpath (
34543469 arrow_path , in_f , tolerance = 0.01 )
34553470 path_tail = path_out
@@ -3467,7 +3482,7 @@ def transmute(self, path, mutation_size, linewidth):
34673482 w1 = 1. , wm = 0.6 , w2 = 0.3 )
34683483
34693484 # path for head
3470- in_f = inside_circle (x0 , y0 , tail_width * .3 )
3485+ in_f = _inside_circle (x0 , y0 , tail_width * .3 )
34713486 path_in , path_out = split_bezier_intersecting_with_closedpath (
34723487 arrow_path , in_f , tolerance = 0.01 )
34733488 tail_start = path_in [- 1 ]
0 commit comments