diff options
| author | Lex Neva <github.com@lexneva.name> | 2022-08-25 23:10:16 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2023-02-20 15:27:35 -0500 |
| commit | 8cead6e3d9f9223bd4d74b30ec6964802f52d9b2 (patch) | |
| tree | 48b567090614aaee995c1a8ffdfa92321182d9cb /lib/stitches | |
| parent | 0ace1ce72c72aa3293d97e5d55e9e614b66d5ee2 (diff) | |
add smoothness option for contour fill
Diffstat (limited to 'lib/stitches')
| -rw-r--r-- | lib/stitches/contour_fill.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/stitches/contour_fill.py b/lib/stitches/contour_fill.py index 885a7e6c..8e47518f 100644 --- a/lib/stitches/contour_fill.py +++ b/lib/stitches/contour_fill.py @@ -406,11 +406,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 |
