summaryrefslogtreecommitdiff
path: root/lib/extensions
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2020-03-18 23:07:36 -0400
committerLex Neva <github.com@lexneva.name>2020-03-18 23:07:36 -0400
commit515f2a059e6384e4df55a8645a646aebb626f19c (patch)
treee46f27419d576b6661998cea306b618ca14b0097 /lib/extensions
parentbabd4884ddc7a3f0d6a47f52e5e3c27ddfda10be (diff)
avoid infinite recursion
Diffstat (limited to 'lib/extensions')
-rw-r--r--lib/extensions/convert_to_satin.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/extensions/convert_to_satin.py b/lib/extensions/convert_to_satin.py
index cf292281..f3924659 100644
--- a/lib/extensions/convert_to_satin.py
+++ b/lib/extensions/convert_to_satin.py
@@ -54,7 +54,7 @@ class ConvertToSatin(InkstitchExtension):
parent.remove(element.node)
- def convert_path_to_satins(self, path, stroke_width, style_args, correction_transform, path_style):
+ def convert_path_to_satins(self, path, stroke_width, style_args, correction_transform, path_style, depth=0):
try:
rails, rungs = self.path_to_satin(path, stroke_width, style_args)
yield self.satin_to_svg_node(rails, rungs, correction_transform, path_style)
@@ -62,11 +62,16 @@ class ConvertToSatin(InkstitchExtension):
# The path intersects itself. Split it in two and try doing the halves
# individually.
+ if depth >= 20:
+ # At this point we're slicing the path way too small and still
+ # getting nowhere. Just give up on this section of the path.
+ return
+
half = int(len(path) / 2.0)
halves = [path[:half + 1], path[half:]]
for path in halves:
- for satin in self.convert_path_to_satins(path, stroke_width, style_args, correction_transform, path_style):
+ for satin in self.convert_path_to_satins(path, stroke_width, style_args, correction_transform, path_style, depth=depth + 1):
yield satin
def fix_loop(self, path):