8000 update fix based on anntzer's suggestion · matplotlib/matplotlib@66403eb · GitHub
[go: up one dir, main page]

Skip to content

Commit 66403eb

Browse files
committed
update fix based on anntzer's suggestion
1 parent b093511 commit 66403eb

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

lib/matplotlib/patches.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,23 +137,17 @@ def contains(self, mouseevent, radius=None):
137137
"""
138138
if callable(self._contains):
139139
return self._contains(self, mouseevent)
140-
inside = False
141-
start = 0
142140
radius = self._process_radius(radius)
143141
codes = self.get_path().codes
144142
vertices = self.get_path().vertices
145-
for i in range(1, len(codes)+1):
146-
# fix bug (#8384)
147-
# if current path is concatenated by multiple pathes
148-
# check if any subpath contains the point.
149-
if (i == len(codes)) or (codes[i] == 1):
150-
path = Path(np.concatenate([vertices[start: i]]),
151-
np.concatenate([codes[start: i]]))
152-
inside = inside or path.contains_point(
153-
(mouseevent.x, mouseevent.y), self.get_transform(), radius
154-
)
155-
start = i
156-
return inside, {}
143+
idxs, = np.nonzero(codes == 1)
144+
# Don't split before the first MOVETO.
145+
idxs = idxs[1:]
146+
return any(
147+
subpath.contains_point(
148+
(mouseevent.x, mouseevent.y), self.get_transform(), radius)
149+
for subpath in map(
150+
Path, np.split(vertices, idxs), np.split(codes, idxs))), {}
157151

158152
def contains_point(self, point, radius=None):
159153
"""

0 commit comments

Comments
 (0)
0