summaryrefslogtreecommitdiff
path: root/lib/stitches
diff options
context:
space:
mode:
authorKaalleen <reni@allenka.de>2023-05-14 09:11:33 +0200
committerKaalleen <reni@allenka.de>2023-05-14 09:11:33 +0200
commit6931d4868d05128b4bb148fe1714dedc808591b4 (patch)
treec6c3771287066ff55f49dd922fff5be532510c1c /lib/stitches
parent111fd8f0ef7bc8e62322c38a7a7467c453f85331 (diff)
ripple: line count
Diffstat (limited to 'lib/stitches')
-rw-r--r--lib/stitches/ripple_stitch.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/stitches/ripple_stitch.py b/lib/stitches/ripple_stitch.py
index 52d91c2d..80800b04 100644
--- a/lib/stitches/ripple_stitch.py
+++ b/lib/stitches/ripple_stitch.py
@@ -103,15 +103,7 @@ def _get_satin_line_count(stroke, pairs):
if shortest_line_len == 0 or length < shortest_line_len:
shortest_line_len = length
num_lines = ceil(shortest_line_len / stroke.min_line_dist)
- # We want the line count always to be either even or odd - depending on the line count value.
- # So that the end point stays the same even if the design is resized. This is necessary to enable
- # the user to carefully plan the output and and connect the end point to the following object
- if stroke.line_count % 2 != num_lines % 2:
- num_lines -= 1
- # for flat join styles we need to add an other line
- if stroke.join_style == 1:
- num_lines += 1
- return num_lines
+ return _line_count_adjust(stroke, num_lines)
def _get_target_line_count(stroke, target, outline):
@@ -123,9 +115,19 @@ def _get_guided_line_count(stroke, guide_line):
num_lines = stroke.line_count
else:
num_lines = ceil(guide_line.length / stroke.min_line_dist)
+ return _line_count_adjust(stroke, num_lines)
+
+
+def _line_count_adjust(stroke, num_lines):
+ if stroke.min_line_dist and stroke.line_count % 2 != num_lines % 2:
+ # We want the line count always to be either even or odd - depending on the line count value.
+ # So that the end point stays the same even if the design is resized. This is necessary to enable
+ # the user to carefully plan the output and and connect the end point to the following object
+ num_lines -= 1
if stroke.is_closed or stroke.join_style == 1:
+ # for flat join styles we need to add an other line
num_lines += 1
- return num_lines
+ return max(1, num_lines)
def _get_helper_lines(stroke):