Skip to content

Commit 1cf5592

Browse files
committed
moved inside_circle to private patches func
1 parent 33e042e commit 1cf5592

File tree

2 files changed

+24
-28
lines changed

2 files changed

+24
-28
lines changed

lib/matplotlib/bezier.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -223,26 +223,6 @@ def split_bezier_intersecting_with_closedpath(
223223
return _left, _right
224224

225225

226-
# matplotlib specific
227-
228-
229-
def inside_circle(cx, cy, r):
230-
"""
231-
Return a function that checks whether a point is in a circle with center
232-
(*cx*, *cy*) and radius *r*.
233-
234-
The returned function has the signature::
235-
236-
f(xy: Tuple[float, float]) -> bool
237-
"""
238-
r2 = r ** 2
239-
240-
def _f(xy):
241-
x, y = xy
242-
return (x - cx) ** 2 + (y - cy) ** 2 < r2
243-
return _f
244-
245-
246226
# quadratic Bezier lines
247227

248228

lib/matplotlib/patches.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,27 @@
1111
from . import artist, cbook, colors, docstring, lines as mlines, transforms
1212
from .bezier import (
1313
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)
1615
from .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"],
@@ -2438,13 +2454,13 @@ def _shrink(self, path, shrinkA, shrinkB):
24382454
Shrink the path by fixed size (in points) with shrinkA and shrinkB.
24392455
"""
24402456
if shrinkA:
2441-
insideA = inside_circle(*path.vertices[0], shrinkA)
2457+
insideA = _inside_circle(*path.vertices[0], shrinkA)
24422458
try:
24432459
left, path = path.split_path_inout(insideA)
24442460
except ValueError:
24452461
pass
24462462
if shrinkB:
2447-
insideB = inside_circle(*path.vertices[-1], shrinkB)
2463+
insideB = _inside_circle(*path.vertices[-1], shrinkB)
24482464
try:
24492465
path, right = path.split_path_inout(insideB)
24502466
except ValueError:
@@ -3339,7 +3355,7 @@ def transmute(self, path, mutation_size, linewidth):
33393355

33403356
# divide the path into a head and a tail
33413357
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)
33433359
arrow_path = [(x0, y0), (x1, y1), (x2, y2)]
33443360

33453361
try:
@@ -3422,7 +3438,7 @@ def transmute(self, path, mutation_size, linewidth):
34223438
arrow_path = [(x0, y0), (x1, y1), (x2, y2)]
34233439

34243440
# path for head
3425-
in_f = inside_circle(x2, y2, head_length)
3441+
in_f = _inside_circle(x2, y2, head_length)
34263442
try:
34273443
path_out, path_in = split_bezier_intersecting_with_closedpath(
34283444
arrow_path, in_f, tolerance=0.01)
@@ -3437,7 +3453,7 @@ def transmute(self, path, mutation_size, linewidth):
34373453
path_head = path_in
34383454

34393455
# path for head
3440-
in_f = inside_circle(x2, y2, head_length * .8)
3456+
in_f = _inside_circle(x2, y2, head_length * .8)
34413457
path_out, path_in = split_bezier_intersecting_with_closedpath(
34423458
arrow_path, in_f, tolerance=0.01)
34433459
path_tail = path_out
@@ -3455,7 +3471,7 @@ def transmute(self, path, mutation_size, linewidth):
34553471
w1=1., wm=0.6, w2=0.3)
34563472

34573473
# path for head
3458-
in_f = inside_circle(x0, y0, tail_width * .3)
3474+
in_f = _inside_circle(x0, y0, tail_width * .3)
34593475
path_in, path_out = split_bezier_intersecting_with_closedpath(
34603476
arrow_path, in_f, tolerance=0.01)
34613477
tail_start = path_in[-1]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy