summaryrefslogtreecommitdiff
path: root/lib/elements
diff options
context:
space:
mode:
Diffstat (limited to 'lib/elements')
-rw-r--r--lib/elements/element.py12
-rw-r--r--lib/elements/satin_column.py12
-rw-r--r--lib/elements/stroke.py18
3 files changed, 27 insertions, 15 deletions
diff --git a/lib/elements/element.py b/lib/elements/element.py
index 8e66db58..9b438f56 100644
--- a/lib/elements/element.py
+++ b/lib/elements/element.py
@@ -161,7 +161,11 @@ class EmbroideryElement(object):
try:
params = [int(param) for param in params if param]
except (TypeError, ValueError):
- return [int(default)]
+ params = [int(default)]
+
+ if param.endswith('_mm'):
+ params = [value * PIXELS_PER_MM for value in params]
+
return params
# returns an array of multiple space separated float values
@@ -171,7 +175,11 @@ class EmbroideryElement(object):
try:
params = [float(param) for param in params if param]
except (TypeError, ValueError):
- return [float(default)]
+ params = [float(default)]
+
+ if param.endswith('_mm'):
+ params = [value * PIXELS_PER_MM for value in params]
+
return params
def get_json_param(self, param, default=None):
diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py
index 6babc851..277c4f84 100644
--- a/lib/elements/satin_column.py
+++ b/lib/elements/satin_column.py
@@ -1117,14 +1117,16 @@ class SatinColumn(EmbroideryElement):
linestring = shgeo.LineString(stitches)
return linestring
- def _get_center_line_stitches(self, position):
+ def _get_center_line_stitches(self, position, stitch_length=None):
inset_prop = -np.array([position, 100-position]) / 100
+ if stitch_length is None:
+ stitch_length = self.running_stitch_length
# Do it like contour underlay, but inset all the way to the center.
pairs = self.plot_points_on_rails(self.running_stitch_tolerance, (0, 0), inset_prop)
points = [points[0] for points in pairs]
- stitches = running_stitch.even_running_stitch(points, self.running_stitch_length, self.running_stitch_tolerance)
+ stitches = running_stitch.even_running_stitch(points, [stitch_length], self.running_stitch_tolerance)
if len(stitches) == 1:
stitches.append(stitches[0])
@@ -1338,12 +1340,12 @@ class SatinColumn(EmbroideryElement):
first_side = running_stitch.even_running_stitch(
[points[0] for points in pairs],
- self.contour_underlay_stitch_length,
+ [self.contour_underlay_stitch_length],
self.contour_underlay_stitch_tolerance
)
second_side = running_stitch.even_running_stitch(
[points[1] for points in pairs],
- self.contour_underlay_stitch_length,
+ [self.contour_underlay_stitch_length],
self.contour_underlay_stitch_tolerance
)
@@ -1381,7 +1383,7 @@ class SatinColumn(EmbroideryElement):
repeats = self.center_walk_underlay_repeats
stitch_groups = []
- stitches = self._get_center_line_stitches(self.center_walk_underlay_position)
+ stitches = self._get_center_line_stitches(self.center_walk_underlay_position, self.center_walk_underlay_stitch_length)
if end_point:
tags = ("satin_column", "satin_column_underlay", "satin_center_walk")
stitches = shgeo.LineString(stitches)
diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py
index 58cc5756..f0f44827 100644
--- a/lib/elements/stroke.py
+++ b/lib/elements/stroke.py
@@ -118,14 +118,15 @@ class Stroke(EmbroideryElement):
@property
@param('running_stitch_length_mm',
_('Running stitch length'),
- tooltip=_('Length of stitches. Stitches can be shorter according to the stitch tolerance setting.'),
+ tooltip=_('Length of stitches. Stitches can be shorter according to the stitch tolerance setting.\n'
+ 'It is possible to create stitch length patterns by adding multiple values separated by a space.'),
unit='mm',
- type='float',
+ type='string',
select_items=[('stroke_method', 'running_stitch'), ('stroke_method', 'ripple_stitch')],
- default=2.5,
+ default="2.5",
sort_index=4)
def running_stitch_length(self):
- return max(self.get_float_param("running_stitch_length_mm", 2.5), 0.01)
+ return [max(value, 0.01) for value in self.get_multiple_float_param("running_stitch_length_mm", "2.5")]
@property
@param('running_stitch_tolerance_mm',
@@ -185,13 +186,13 @@ class Stroke(EmbroideryElement):
_('Zig-zag spacing (peak-to-peak)'),
tooltip=_('Length of stitches in zig-zag mode.'),
unit='mm',
- type='float',
- default=0.4,
+ type='string',
+ default="0.4",
select_items=[('stroke_method', 'zigzag_stitch')],
sort_index=6)
@cache
def zigzag_spacing(self):
- return max(self.get_float_param("zigzag_spacing_mm", 0.4), 0.01)
+ return [max(value, 0.01) for value in self.get_multiple_float_param("zigzag_spacing_mm", "0.4")]
@property
@param('stroke_pull_compensation_mm',
@@ -551,7 +552,8 @@ class Stroke(EmbroideryElement):
# `self.zigzag_spacing` is the length for a zig and a zag
# together (a V shape). Start with running stitch at half
# that length:
- stitch_group = self.running_stitch(path, zigzag_spacing / 2.0, self.running_stitch_tolerance, False, 0, "")
+ spacing = [value / 2 for value in zigzag_spacing]
+ stitch_group = self.running_stitch(path, spacing, self.running_stitch_tolerance, False, 0, "")
stitch_group.stitches = zigzag_stitch(stitch_group.stitches, zigzag_spacing, stroke_width, pull_compensation)
return stitch_group