diff options
| author | George Steel <george.steel@gmail.com> | 2023-01-07 19:27:35 -0500 |
|---|---|---|
| committer | George Steel <george.steel@gmail.com> | 2023-01-07 19:27:35 -0500 |
| commit | f69bd1654ae344b0f81f2caea6ef58846eb6e866 (patch) | |
| tree | 8392ef0900ad8308a9819654cf6f5c0f8f40ab61 /lib/extensions/jump_to_stroke.py | |
| parent | d416407f2bb447a655266ae926337be853e88217 (diff) | |
| parent | a7b2122d91703d72177cf980cecbef8fca3d54ec (diff) | |
Merge branch 'main' of https://github.com/inkstitch/inkstitch into george-steel/random-base-satin
Diffstat (limited to 'lib/extensions/jump_to_stroke.py')
| -rw-r--r-- | lib/extensions/jump_to_stroke.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/extensions/jump_to_stroke.py b/lib/extensions/jump_to_stroke.py index 7cf6ff17..ce29a928 100644 --- a/lib/extensions/jump_to_stroke.py +++ b/lib/extensions/jump_to_stroke.py @@ -1,12 +1,13 @@ # Authors: see git history # -# Copyright (c) 2010 Authors +# Copyright (c) 2023 Authors # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. from inkex import DirectedLineSegment, PathElement, errormsg from ..i18n import _ from ..svg import PIXELS_PER_MM, get_correction_transform +from ..svg.tags import INKSTITCH_ATTRIBS from .base import InkstitchExtension @@ -14,6 +15,11 @@ class JumpToStroke(InkstitchExtension): """Adds a running stitch as a connection between two (or more) selected elements. The elements must have the same color and a minimum distance (collapse_len).""" + def __init__(self, *args, **kwargs): + InkstitchExtension.__init__(self, *args, **kwargs) + self.arg_parser.add_argument("-l", "--stitch-length", type=float, default=2.5, dest="running_stitch_length_mm") + self.arg_parser.add_argument("-t", "--tolerance", type=float, default=2.0, dest="running_stitch_tolerance_mm") + def effect(self): if not self.svg.selection or not self.get_elements() or len(self.elements) < 2: errormsg(_("Please select at least two elements to convert the jump stitch to a running stitch.")) @@ -49,6 +55,8 @@ class JumpToStroke(InkstitchExtension): style = f'stroke:{color};stroke-width:1px;stroke-dasharray:3, 1;fill:none;' line = PathElement(d=path, style=style, transform=get_correction_transform(node)) + line.set(INKSTITCH_ATTRIBS['running_stitch_length_mm'], self.options.running_stitch_length_mm) + line.set(INKSTITCH_ATTRIBS['running_stitch_tolerance_mm'], self.options.running_stitch_tolerance_mm) parent.insert(index, line) |
