summaryrefslogtreecommitdiff
path: root/lib/elements
diff options
context:
space:
mode:
Diffstat (limited to 'lib/elements')
-rw-r--r--lib/elements/fill_stitch.py7
-rw-r--r--lib/elements/satin_column.py8
-rw-r--r--lib/elements/stroke.py12
-rw-r--r--lib/elements/utils.py2
4 files changed, 21 insertions, 8 deletions
diff --git a/lib/elements/fill_stitch.py b/lib/elements/fill_stitch.py
index 80e68247..b93d7ff5 100644
--- a/lib/elements/fill_stitch.py
+++ b/lib/elements/fill_stitch.py
@@ -364,12 +364,11 @@ class FillStitch(EmbroideryElement):
@property
@param('running_stitch_tolerance_mm',
_('Running stitch tolerance'),
- tooltip=_('All stitches must be within this distance of the path. ' +
- 'A lower tolerance means stitches will be closer together. ' +
- 'A higher tolerance means sharp corners may be rounded.'),
+ tooltip=_('Determines how hard Ink/Stitch tries to avoid stitching outside the shape.' +
+ 'Lower numbers are less likely to stitch outside the shape but require more stitches.'),
unit='mm',
type='float',
- default=0.2,
+ default=0.1,
sort_index=32)
def running_stitch_tolerance(self):
return max(self.get_float_param("running_stitch_tolerance_mm", 0.2), 0.01)
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
diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py
index ac54908b..d845ed01 100644
--- a/lib/elements/stroke.py
+++ b/lib/elements/stroke.py
@@ -31,6 +31,15 @@ class MultipleGuideLineWarning(ValidationWarning):
]
+class TooFewSubpathsWarning(ValidationWarning):
+ name = _("Too few subpaths")
+ description = _("This element renders as running stitch while it has a satin column parameter.")
+ steps_to_solve = [
+ _("* Convert to stroke: select the element and open the parameter dialog. Enable running stitch along path."),
+ _("* Use as satin column: add an other rail and optionally rungs.")
+ ]
+
+
class Stroke(EmbroideryElement):
element_name = _("Stroke")
@@ -567,6 +576,9 @@ class Stroke(EmbroideryElement):
return coords[int(len(coords)/2)]
def validation_warnings(self):
+ # satin column warning
+ if self.get_boolean_param("satin_column", False):
+ yield TooFewSubpathsWarning(self._representative_point())
# guided fill warnings
if self.stroke_method == 1:
guide_lines = get_marker_elements(self.node, "guide-line", False, True, True)
diff --git a/lib/elements/utils.py b/lib/elements/utils.py
index f7ee8dbc..d5122e3f 100644
--- a/lib/elements/utils.py
+++ b/lib/elements/utils.py
@@ -41,7 +41,7 @@ def node_to_elements(node, clone_to_element=False): # noqa: C901
if element.get_style("fill", "black") and not element.get_style('fill-opacity', 1) == "0":
elements.append(FillStitch(node))
if element.get_style("stroke"):
- if element.get_boolean_param("satin_column"):
+ if element.get_boolean_param("satin_column") and len(element.path) > 1:
elements.append(SatinColumn(node))
elif not is_command(element.node):
elements.append(Stroke(node))