diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2023-05-16 16:58:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-16 16:58:17 +0200 |
| commit | 1193b4f2062d2bc4114fefe29992553c59200090 (patch) | |
| tree | 5f43833eed5facdf9ec35d0b755a6fe492b9bfa2 /lib/stitches/ripple_stitch.py | |
| parent | 02738ec46e333a53c9970fd936340e88f6108ffb (diff) | |
| parent | 66068208e87f5464fa6b8038b74fe95de6b21bb9 (diff) | |
Merge pull request #2284 from inkstitch/kaalleen/various-fixes
Diffstat (limited to 'lib/stitches/ripple_stitch.py')
| -rw-r--r-- | lib/stitches/ripple_stitch.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/stitches/ripple_stitch.py b/lib/stitches/ripple_stitch.py index 4e1c563e..40a522eb 100644 --- a/lib/stitches/ripple_stitch.py +++ b/lib/stitches/ripple_stitch.py @@ -103,9 +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) - 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): @@ -117,7 +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 + # ensure minimum line count + num_lines = max(1, num_lines) 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 |
