diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py index 0850d313e..4d3bbdc3d 100644 --- a/lib/elements/satin_column.py +++ b/lib/elements/satin_column.py @@ -2,11 +2,12 @@ # # Copyright (c) 2010 Authors # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. + import random from copy import deepcopy from itertools import chain -import numpy as np +import numpy as np from inkex import paths from shapely import affinity as shaffinity from shapely import geometry as shgeo @@ -96,36 +97,31 @@ class SatinColumn(EmbroideryElement): return min(max(self.get_int_param("random_split_factor", 0), 0), 100) @property - @param('random_first_rail_factor_in', - _('First Rail Random Factor inside'), - tooltip=_('shorten stitch around first rail at most this percent.'), - type='int', unit="%", sort_index=60) - def random_first_rail_factor_in(self): - return min(max(self.get_int_param("random_first_rail_factor_in", 0), 0), 100) + @param('random_zigzag_spacing', + _('Zig-zag spacing randomness(peak-to-peak)'), + tooltip=_('percentage of randomness of Peak-to-peak distance between zig-zags.'), + type='int', unit="%", sort_index=64) + def random_zigzag_spacing(self): + # peak-to-peak distance between zigzags + return max(self.get_int_param("random_zigzag_spacing", 0), 0) @property - @param('random_first_rail_factor_out', - _('First Rail Random Factor outside'), - tooltip=_('lengthen stitch around first rail at most this percent.'), - type='int', unit="%", sort_index=61) - def random_first_rail_factor_out(self): - return max(self.get_int_param("random_first_rail_factor_out", 0), 0) + @param('random_width_decrease_percent', + _('Random percentage of satin width decrease'), + tooltip=_('shorten stitch across rails at most this percent.' + 'Two values separated by a space may be used for an aysmmetric effect.'), + type='int', unit="% (each side)", sort_index=60) + def random_width_decrease_percent(self): + return self.get_split_float_param("random_width_decrease_percent", (0, 0)) @property - @param('random_second_rail_factor_in', - _('Second Rail Random Factor inside'), - tooltip=_('shorten stitch around second rail at most this percent.'), - type='int', unit="%", sort_index=62) - def random_second_rail_factor_in(self): - return min(max(self.get_int_param("random_second_rail_factor_in", 0), 0), 100) - - @property - @param('random_second_rail_factor_out', - _('Second Rail Random Factor outside'), - tooltip=_('lengthen stitch around second rail at most this percent.'), - type='int', unit="%", sort_index=63) - def random_second_rail_factor_out(self): - return max(self.get_int_param("random_second_rail_factor_out", 0), 0) + @param('random_width_increase_percent', + _('Random percentage of satin width increase'), + tooltip=_('lengthen stitch across rails at most this percent.' + 'Two values separated by a space may be used for an aysmmetric effect.'), + type='int', unit="% (each side)", sort_index=60) + def random_width_increase_percent(self): + return self.get_split_float_param("random_width_increase_percent", (0, 0)) @property @param('short_stitch_inset', @@ -160,15 +156,6 @@ class SatinColumn(EmbroideryElement): # peak-to-peak distance between zigzags return max(self.get_float_param("zigzag_spacing_mm", 0.4), 0.01) - @property - @param('random_zigzag_spacing', - _('Zig-zag spacing randomness(peak-to-peak)'), - tooltip=_('percentage of randomness of Peak-to-peak distance between zig-zags.'), - type='int', unit="%", sort_index=64) - def random_zigzag_spacing(self): - # peak-to-peak distance between zigzags - return max(self.get_int_param("random_zigzag_spacing", 0), 0) - @property @param( 'pull_compensation_percent', @@ -550,7 +537,7 @@ class SatinColumn(EmbroideryElement): for rung in self.rungs: point_lists.append(self.flatten_subpath(rung)) - # If originally there were only two subpaths (no rungs) with same number of rails, we may the rails may now + # If originally there were only two subpaths (no rungs) with same number of rails, the rails may now # have two rails with different number of points, and still no rungs, let's add one. if not self.rungs: @@ -841,11 +828,9 @@ class SatinColumn(EmbroideryElement): if to_travel <= 0: - decalage0 = random.uniform(-self.random_first_rail_factor_in, self.random_first_rail_factor_out) / 100 - decalage1 = random.uniform(-self.random_second_rail_factor_in, self.random_second_rail_factor_out) / 100 - - add_pair(pos0 + (pos0 - pos1) * decalage0, pos1 + (pos1 - pos0) * decalage1) - + mismatch0 = random.uniform(-self.random_width_decrease_percent[0], self.random_width_increase_percent[0]) / 100 + mismatch1 = random.uniform(-self.random_width_decrease_percent[1], self.random_width_increase_percent[1]) / 100 + add_pair(pos0 + (pos0 - pos1) * mismatch0, pos1 + (pos1 - pos0) * mismatch1) to_travel = spacing * (random.uniform(1, 1 + self.random_zigzag_spacing/100)) if to_travel > 0: @@ -1023,10 +1008,10 @@ class SatinColumn(EmbroideryElement): points = [] distance = left.distance(right) split_count = count or int(-(-distance // max_stitch_length)) + random_move = 0 for i in range(split_count): line = shgeo.LineString((left, right)) - random_move = 0 if self.random_split_factor and i != split_count-1: random_move = random.uniform(-self.random_split_factor / 100, self.random_split_factor / 100) diff --git a/lib/svg/tags.py b/lib/svg/tags.py index 4743438b3..54400c4e1 100644 --- a/lib/svg/tags.py +++ b/lib/svg/tags.py @@ -123,11 +123,9 @@ inkstitch_attribs = [ 'pull_compensation_mm', 'pull_compensation_percent', 'stroke_first', + 'random_width_decrease_percent', + 'random_width_increase_percent', 'random_split_factor', - 'random_first_rail_factor_in', - 'random_first_rail_factor_out', - 'random_second_rail_factor_in', - 'random_second_rail_factor_out', 'random_zigzag_spacing', 'use_seed', # stitch_plan