summaryrefslogtreecommitdiff
path: root/embroider.py
diff options
context:
space:
mode:
authorLex Neva <github@lexneva.name>2017-10-28 21:27:16 +0100
committerLex Neva <github@lexneva.name>2017-10-28 21:27:16 +0100
commitbd50c08b5db2b5a90c5b01af4eaf7ef0c713d4e4 (patch)
tree28a0dfa56adaf676a27ce60912a2f4df690c4f7c /embroider.py
parent806123b6acbb3fdde7a757734085463283a22ef0 (diff)
fix occasional failure of which_outline()
Diffstat (limited to 'embroider.py')
-rw-r--r--embroider.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/embroider.py b/embroider.py
index dbf07c1e..09b89d13 100644
--- a/embroider.py
+++ b/embroider.py
@@ -608,13 +608,14 @@ class AutoFill(Fill):
outlines of the holes.
"""
+ # I'd use an intersection check, but floating point errors make it
+ # fail sometimes.
+
point = shgeo.Point(*coords)
+ outlines = list(enumerate(self.shape.boundary))
+ closest = min(outlines, key=lambda (index, outline): outline.distance(point))
- for i, outline in enumerate(self.shape.boundary):
- # I'd use an intersection check, but floating point errors make it
- # fail sometimes.
- if outline.distance(point) < 0.00001:
- return i
+ return closest[0]
def project(self, coords, outline_index):
"""project the point onto the specified outline