diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2024-12-26 16:19:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-26 16:19:35 +0100 |
| commit | ef7d056173cc6d7782d6120c031dae9276725a3d (patch) | |
| tree | 75d2ef67976336a93424b504e42bbf1a394b9a49 /lib/extensions | |
| parent | e20161a4ec9a69cb0f1bdfdd16bcd27a8601fde7 (diff) | |
End points (#3370)
* end at nearest point to next element (if requested and possible)
Diffstat (limited to 'lib/extensions')
| -rw-r--r-- | lib/extensions/base.py | 9 | ||||
| -rwxr-xr-x | lib/extensions/params.py | 9 |
2 files changed, 13 insertions, 5 deletions
diff --git a/lib/extensions/base.py b/lib/extensions/base.py index 5f840417..4a2895d0 100644 --- a/lib/extensions/base.py +++ b/lib/extensions/base.py @@ -7,11 +7,11 @@ import os import inkex +from ..elements.utils import iterate_nodes, nodes_to_elements from ..i18n import _ from ..metadata import InkStitchMetadata from ..svg import generate_unique_id from ..svg.tags import INKSCAPE_GROUPMODE, SVG_GROUP_TAG -from ..elements.utils import iterate_nodes, nodes_to_elements from ..update import update_inkstitch_document @@ -75,14 +75,17 @@ class InkstitchExtension(inkex.EffectExtension): return False def elements_to_stitch_groups(self, elements): + next_elements = [None] + if len(elements) > 1: + next_elements = elements[1:] + next_elements stitch_groups = [] - for element in elements: + for element, next_element in zip(elements, next_elements): if stitch_groups: last_stitch_group = stitch_groups[-1] else: last_stitch_group = None - stitch_groups.extend(element.embroider(last_stitch_group)) + stitch_groups.extend(element.embroider(last_stitch_group, next_element)) return stitch_groups diff --git a/lib/extensions/params.py b/lib/extensions/params.py index dd5c427c..0cac9365 100755 --- a/lib/extensions/params.py +++ b/lib/extensions/params.py @@ -563,12 +563,12 @@ class SettingsPanel(wx.Panel): try: wx.CallAfter(self._hide_warning) last_stitch_group = None - for node in nodes: + for node, next_node in zip_longest(nodes, self._get_next_nodes(nodes)): # Making a copy of the embroidery element is an easy # way to drop the cache in the @cache decorators used # for many params in embroider.py. - stitch_groups.extend(copy(node).embroider(last_stitch_group)) + stitch_groups.extend(copy(node).embroider(last_stitch_group, next_node)) if stitch_groups: last_stitch_group = stitch_groups[-1] @@ -587,6 +587,11 @@ class SettingsPanel(wx.Panel): except Exception: wx.CallAfter(self._show_warning, format_uncaught_exception()) + def _get_next_nodes(self, nodes): + if len(nodes) > 1: + return nodes[1:] + return [] + def get_stroke_last_tabs(self): tabs = self.tabs stroke_index = [tabs.index(tab) for tab in tabs if tab.name == _("Stroke")] |
