@@ -252,6 +252,8 @@ def _get_staggered_stitches(stroke, lines, skip_start):
252252 random_seed = stroke .random_seed
253253 last_point = None
254254 for i , line in enumerate (lines ):
255+ if len (line ) == 1 :
256+ continue
255257 connector = []
256258 if i != 0 and stroke .join_style == 0 :
257259 if i % 2 == 0 or not stroke .flip_copies :
@@ -270,21 +272,10 @@ def _get_staggered_stitches(stroke, lines, skip_start):
270272 line .reverse ()
271273 stitched_line = running_stitch (line , stitch_length , tolerance , is_random , length_sigma , prng .join_args (random_seed , i ))
272274 else :
273- if len (stitch_length ) > 1 :
274- points = list (
275- apply_stagger (line , stitch_length , stroke .staggers , i , tolerance , is_random , length_sigma , prng .join_args (random_seed , i )).coords
276- )
277- else :
278- # uses the guided fill alforithm to stagger rows of stitches
279- points = list (apply_stitches (LineString (line ), stitch_length , stroke .staggers , 0.5 , i , tolerance ).coords )
280-
281- # simplifying the path in apply_stitches could have removed the start or end point
282- # we can simply add it again, the minimum stitch length value will take care to remove possible duplicates
283- points = [line [0 ]] + points + [line [- 1 ]]
284-
285- stitched_line = [InkstitchPoint (* point ) for point in points ]
286- if should_reverse and stroke .flip_copies :
287- stitched_line .reverse ()
275+ stitched_line = _stagger_line (
276+ line , stitch_length , stroke .staggers , i , tolerance , is_random , length_sigma , prng .join_args (random_seed , i ),
277+ should_reverse , stroke .flip_copies
278+ )
288279
289280 stitched_line = connector + stitched_line
290281
@@ -293,6 +284,25 @@ def _get_staggered_stitches(stroke, lines, skip_start):
293284 return stitches
294285
295286
287+ def _stagger_line (line , stitch_length , staggers , i , tolerance , is_random , length_sigma , random , should_reverse , flip_copies ):
288+ if len (stitch_length ) > 1 :
289+ points = list (
290+ apply_stagger (line , stitch_length , staggers , i , tolerance , is_random , length_sigma , random ).coords
291+ )
292+ else :
293+ # uses the guided fill alforithm to stagger rows of stitches
294+ points = list (apply_stitches (LineString (line ), stitch_length , staggers , 0.5 , i , tolerance ).coords )
295+
296+ # simplifying the path in apply_stitches could have removed the start or end point
297+ # we can simply add it again, the minimum stitch length value will take care to remove possible duplicates
298+ points = [line [0 ]] + points + [line [- 1 ]]
299+
300+ stitched_line = [InkstitchPoint (* point ) for point in points ]
301+ if should_reverse and flip_copies :
302+ stitched_line .reverse ()
303+ return stitched_line
304+
305+
296306def apply_stagger (line , stitch_length , num_staggers , row_num , tolerance , is_random , stitch_length_sigma , random_seed ):
297307 if num_staggers == 0 :
298308 num_staggers = 1 # sanity check to avoid division by zero.
@@ -591,6 +601,8 @@ def _get_start_rotation(line):
591601
592602def generate_satin_guide_helper_lines (stroke , outline , guide_line ):
593603 anchor_line = stroke .get_anchor_line ()
604+ guide_line .node .set ('inkstitch:reverse_rails' , stroke .reverse_rails )
605+ guide_line .node .set ('inkstitch:swap_satin_rails' , stroke .swap_rails )
594606 if anchor_line :
595607 # position, rotation and scale defined by anchor line
596608 outline0 = InkstitchPoint (* anchor_line .coords [0 ])
0 commit comments