11
11
from . import artist , cbook , colors , docstring , lines as mlines , transforms
12
12
from .bezier import (
13
13
NonIntersectingPathException , get_cos_sin , get_intersection , get_parallels ,
14
- inside_circle , make_wedged_bezier2 ,
15
- split_bezier_intersecting_with_closedpath )
14
+ make_wedged_bezier2 , split_bezier_intersecting_with_closedpath )
16
15
from .path import Path
17
16
18
17
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
+
19
35
@cbook ._define_aliases ({
20
36
"antialiased" : ["aa" ],
21
37
"edgecolor" : ["ec" ],
@@ -2438,13 +2454,13 @@ def _shrink(self, path, shrinkA, shrinkB):
2438
2454
Shrink the path by fixed size (in points) with shrinkA and shrinkB.
2439
2455
"""
2440
2456
if shrinkA :
2441
- insideA = inside_circle (* path .vertices [0 ], shrinkA )
2457
+ insideA = _inside_circle (* path .vertices [0 ], shrinkA )
2442
2458
try :
2443
2459
left , path = path .split_path_inout (insideA )
2444
2460
except ValueError :
2445
2461
pass
2446
2462
if shrinkB :
2447
- insideB = inside_circle (* path .vertices [- 1 ], shrinkB )
2463
+ insideB = _inside_circle (* path .vertices [- 1 ], shrinkB )
2448
2464
try :
2449
2465
path , right = path .split_path_inout (insideB )
2450
2466
except ValueError :
@@ -3339,7 +3355,7 @@ def transmute(self, path, mutation_size, linewidth):
3339
3355
3340
3356
# divide the path into a head and a tail
3341
3357
head_length = self .head_length * mutation_size
3342
- in_f = inside_circle (x2 , y2 , head_length )
3358
+ in_f = _inside_circle (x2 , y2 , head_length )
3343
3359
arrow_path = [(x0 , y0 ), (x1 , y1 ), (x2 , y2 )]
3344
3360
3345
3361
try :
@@ -3422,7 +3438,7 @@ def transmute(self, path, mutation_size, linewidth):
3422
3438
arrow_path = [(x0 , y0 ), (x1 , y1 ), (x2 , y2 )]
3423
3439
3424
3440
# path for head
3425
- in_f = inside_circle (x2 , y2 , head_length )
3441
+ in_f = _inside_circle (x2 , y2 , head_length )
3426
3442
try :
3427
3443
path_out , path_in = split_bezier_intersecting_with_closedpath (
3428
3444
arrow_path , in_f , tolerance = 0.01 )
@@ -3437,7 +3453,7 @@ def transmute(self, path, mutation_size, linewidth):
3437
3453
path_head = path_in
3438
3454
3439
3455
# path for head
3440
- in_f = inside_circle (x2 , y2 , head_length * .8 )
3456
+ in_f = _inside_circle (x2 , y2 , head_length * .8 )
3441
3457
path_out , path_in = split_bezier_intersecting_with_closedpath (
3442
3458
arrow_path , in_f , tolerance = 0.01 )
3443
3459
path_tail = path_out
@@ -3455,7 +3471,7 @@ def transmute(self, path, mutation_size, linewidth):
3455
3471
w1 = 1. , wm = 0.6 , w2 = 0.3 )
3456
3472
3457
3473
# path for head
3458
- in_f = inside_circle (x0 , y0 , tail_width * .3 )
3474
+ in_f = _inside_circle (x0 , y0 , tail_width * .3 )
3459
3475
path_in , path_out = split_bezier_intersecting_with_closedpath (
3460
3476
arrow_path , in_f , tolerance = 0.01 )
3461
3477
tail_start = path_in [- 1 ]
0 commit comments