From 8e70f3d2feaab8a14f775a5ef84002bdab9688f0 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Tue, 26 Mar 2024 07:10:40 +0100 Subject: Add object based min stitch length (#2792) * add object based min stitch length (overwrites global) * add object based minimum jump stitch (overwrites global) * rename patches to stitch_groups --- lib/extensions/base.py | 12 ++++++------ lib/extensions/density_map.py | 4 ++-- lib/extensions/output.py | 4 ++-- lib/extensions/print_pdf.py | 4 ++-- lib/extensions/stitch_plan_preview.py | 4 ++-- lib/extensions/zip.py | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) (limited to 'lib/extensions') diff --git a/lib/extensions/base.py b/lib/extensions/base.py index e0bf4131..4d5aacfe 100644 --- a/lib/extensions/base.py +++ b/lib/extensions/base.py @@ -124,16 +124,16 @@ class InkstitchExtension(inkex.EffectExtension): return False def elements_to_stitch_groups(self, elements): - patches = [] + stitch_groups = [] for element in elements: - if patches: - last_patch = patches[-1] + if stitch_groups: + last_stitch_group = stitch_groups[-1] else: - last_patch = None + last_stitch_group = None - patches.extend(element.embroider(last_patch)) + stitch_groups.extend(element.embroider(last_stitch_group)) - return patches + return stitch_groups def get_inkstitch_metadata(self): return InkStitchMetadata(self.svg) diff --git a/lib/extensions/density_map.py b/lib/extensions/density_map.py index 854a4ebe..e4963bf9 100644 --- a/lib/extensions/density_map.py +++ b/lib/extensions/density_map.py @@ -39,8 +39,8 @@ class DensityMap(InkstitchExtension): self.metadata = self.get_inkstitch_metadata() collapse_len = self.metadata['collapse_len_mm'] min_stitch_len = self.metadata['min_stitch_len_mm'] - patches = self.elements_to_stitch_groups(self.elements) - stitch_plan = stitch_groups_to_stitch_plan(patches, collapse_len=collapse_len, min_stitch_len=min_stitch_len) + stitch_groups = self.elements_to_stitch_groups(self.elements) + stitch_plan = stitch_groups_to_stitch_plan(stitch_groups, collapse_len=collapse_len, min_stitch_len=min_stitch_len) layer = svg.find(".//*[@id='__inkstitch_density_plan__']") color_groups = create_color_groups(layer) diff --git a/lib/extensions/output.py b/lib/extensions/output.py index ef542277..5f2b485d 100644 --- a/lib/extensions/output.py +++ b/lib/extensions/output.py @@ -54,8 +54,8 @@ class Output(InkstitchExtension): self.metadata = self.get_inkstitch_metadata() collapse_len = self.metadata['collapse_len_mm'] min_stitch_len = self.metadata['min_stitch_len_mm'] - patches = self.elements_to_stitch_groups(self.elements) - stitch_plan = stitch_groups_to_stitch_plan(patches, collapse_len=collapse_len, disable_ties=self.settings.get('laser_mode', False), + stitch_groups = self.elements_to_stitch_groups(self.elements) + stitch_plan = stitch_groups_to_stitch_plan(stitch_groups, collapse_len=collapse_len, disable_ties=self.settings.get('laser_mode', False), min_stitch_len=min_stitch_len) ThreadCatalog().match_and_apply_palette(stitch_plan, self.metadata['thread-palette']) diff --git a/lib/extensions/print_pdf.py b/lib/extensions/print_pdf.py index ddfdc3a3..c3c14e48 100644 --- a/lib/extensions/print_pdf.py +++ b/lib/extensions/print_pdf.py @@ -310,8 +310,8 @@ class Print(InkstitchExtension): self.metadata = self.get_inkstitch_metadata() collapse_len = self.metadata['collapse_len_mm'] min_stitch_len = self.metadata['min_stitch_len_mm'] - patches = self.elements_to_stitch_groups(self.elements) - stitch_plan = stitch_groups_to_stitch_plan(patches, collapse_len=collapse_len, min_stitch_len=min_stitch_len) + stitch_groups = self.elements_to_stitch_groups(self.elements) + stitch_plan = stitch_groups_to_stitch_plan(stitch_groups, collapse_len=collapse_len, min_stitch_len=min_stitch_len) palette = ThreadCatalog().match_and_apply_palette(stitch_plan, self.get_inkstitch_metadata()['thread-palette']) overview_svg, color_block_svgs = self.render_svgs(stitch_plan, realistic=False) diff --git a/lib/extensions/stitch_plan_preview.py b/lib/extensions/stitch_plan_preview.py index 224c8d75..541c42f0 100644 --- a/lib/extensions/stitch_plan_preview.py +++ b/lib/extensions/stitch_plan_preview.py @@ -38,8 +38,8 @@ class StitchPlanPreview(InkstitchExtension): self.metadata = self.get_inkstitch_metadata() collapse_len = self.metadata['collapse_len_mm'] min_stitch_len = self.metadata['min_stitch_len_mm'] - patches = self.elements_to_stitch_groups(self.elements) - stitch_plan = stitch_groups_to_stitch_plan(patches, collapse_len=collapse_len, min_stitch_len=min_stitch_len) + stitch_groups = self.elements_to_stitch_groups(self.elements) + stitch_plan = stitch_groups_to_stitch_plan(stitch_groups, collapse_len=collapse_len, min_stitch_len=min_stitch_len) render_stitch_plan(svg, stitch_plan, realistic, visual_commands) # apply options diff --git a/lib/extensions/zip.py b/lib/extensions/zip.py index 24bfc633..9a13ca2d 100644 --- a/lib/extensions/zip.py +++ b/lib/extensions/zip.py @@ -54,8 +54,8 @@ class Zip(InkstitchExtension): self.metadata = self.get_inkstitch_metadata() collapse_len = self.metadata['collapse_len_mm'] min_stitch_len = self.metadata['min_stitch_len_mm'] - patches = self.elements_to_stitch_groups(self.elements) - stitch_plan = stitch_groups_to_stitch_plan(patches, collapse_len=collapse_len, min_stitch_len=min_stitch_len) + stitch_groups = self.elements_to_stitch_groups(self.elements) + stitch_plan = stitch_groups_to_stitch_plan(stitch_groups, collapse_len=collapse_len, min_stitch_len=min_stitch_len) ThreadCatalog().match_and_apply_palette(stitch_plan, self.get_inkstitch_metadata()['thread-palette']) if self.options.x_repeats != 1 or self.options.y_repeats != 1: -- cgit v1.2.3