summaryrefslogtreecommitdiff
path: root/lib/stitches/contour_fill.py
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2023-02-22 20:22:49 -0500
committerGitHub <noreply@github.com>2023-02-22 20:22:49 -0500
commit8cdfaf099864e76a487ce77712ee54682e4a091f (patch)
tree6fd43b320f53d4f81a40c0097091f8e4baaa31ac /lib/stitches/contour_fill.py
parente559af72480858c32f5df57f7f6a0d653718ebf8 (diff)
parent92dff9f359f19c57ce63046a85cbd40746e50a32 (diff)
Merge pull request #1803 from inkstitch/lexelby/smoothing
Meander fill
Diffstat (limited to 'lib/stitches/contour_fill.py')
-rw-r--r--lib/stitches/contour_fill.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/stitches/contour_fill.py b/lib/stitches/contour_fill.py
index 885a7e6c..f5f2a3ee 100644
--- a/lib/stitches/contour_fill.py
+++ b/lib/stitches/contour_fill.py
@@ -12,9 +12,11 @@ from shapely.validation import make_valid
from ..stitch_plan import Stitch
from ..utils import DotDict
+from ..utils.clamp_path import clamp_path_to_polygon
from ..utils.geometry import (cut, ensure_geometry_collection,
ensure_multi_polygon, reverse_line_string,
roll_linear_ring)
+from ..utils.smoothing import smooth_path
from ..utils.threading import check_stop_flag
from .running_stitch import running_stitch
@@ -406,11 +408,16 @@ def _find_path_inner_to_outer(tree, node, offset, starting_point, avoid_self_cro
return LineString(result_coords)
-def inner_to_outer(tree, offset, stitch_length, tolerance, starting_point, avoid_self_crossing):
+def inner_to_outer(tree, polygon, offset, stitch_length, tolerance, smoothness, starting_point, avoid_self_crossing):
"""Fill a shape with spirals, from innermost to outermost."""
stitch_path = _find_path_inner_to_outer(tree, 'root', offset, starting_point, avoid_self_crossing)
points = [Stitch(*point) for point in stitch_path.coords]
+
+ if smoothness > 0:
+ smoothed = smooth_path(points, smoothness)
+ points = clamp_path_to_polygon(smoothed, polygon)
+
stitches = running_stitch(points, stitch_length, tolerance)
return stitches