diff options
Diffstat (limited to 'lib/elements/satin_column.py')
| -rw-r--r-- | lib/elements/satin_column.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py index dc883dea..86c6d05a 100644 --- a/lib/elements/satin_column.py +++ b/lib/elements/satin_column.py @@ -830,6 +830,8 @@ class SatinColumn(EmbroideryElement): def center_line(self): # similar technique to do_center_walk() center_walk = [p[0] for p in self.plot_points_on_rails(self.zigzag_spacing, (0, 0), (-0.5, -0.5))] + if len(center_walk) < 2: + center_walk = [center_walk[0], center_walk[0]] return shgeo.LineString(center_walk) def offset_points(self, pos1, pos2, offset_px, offset_proportional): @@ -907,7 +909,7 @@ class SatinColumn(EmbroideryElement): # Base the number of stitches in each section on the _longer_ of # the two sections. Otherwise, things could get too sparse when one # side is significantly longer (e.g. when going around a corner). - num_points = max(path0.length, path1.length) / spacing + num_points = max(path0.length, path1.length, 0.01) / spacing # Section stitch spacing and the cursor are expressed as a fraction # of the total length of the path, because we use normalized=True @@ -965,7 +967,7 @@ class SatinColumn(EmbroideryElement): # more than 5%. if iterations <= 2: distance = self._stitch_distance(pos0, pos1, old_pos0, old_pos1) - if abs((current_spacing - distance) / current_spacing) > 0.05: + if distance > 0.01 and abs((current_spacing - distance) / current_spacing) > 0.05: # We'll revise to_travel then go back to the start of # the loop and try again. to_travel = (current_spacing / distance) * to_travel @@ -1294,6 +1296,6 @@ class SatinProcessor: if self.use_random: roll = prng.uniform_floats(self.seed, self.cycle) self.cycle += 1 - return 1.0 + ((roll[0] - 0.5) * 2) * self.random_zigzag_spacing + return max(1.0 + ((roll[0] - 0.5) * 2) * self.random_zigzag_spacing, 0.01) else: return 1.0 |
