From 5f23dea1a1fa1708cc66d6aa951970bbd927515f Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Wed, 26 Jun 2024 22:51:15 +0200 Subject: Make PNG (simple/realistic) and threadlist available in export file formats (#3019) --- lib/extensions/png_realistic.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lib/extensions/png_realistic.py (limited to 'lib/extensions/png_realistic.py') diff --git a/lib/extensions/png_realistic.py b/lib/extensions/png_realistic.py new file mode 100644 index 00000000..24ebce55 --- /dev/null +++ b/lib/extensions/png_realistic.py @@ -0,0 +1,32 @@ +# Authors: see git history +# +# Copyright (c) 2024 Authors +# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. + +import sys + +from ..stitch_plan import stitch_groups_to_stitch_plan +from ..svg import render_stitch_plan +from ..threads import ThreadCatalog +from .base import InkstitchExtension +from .png_simple import write_png_output + + +class PngRealistic(InkstitchExtension): + def effect(self): + if not self.get_elements(): + return + + self.metadata = self.get_inkstitch_metadata() + collapse_len = self.metadata['collapse_len_mm'] + min_stitch_len = self.metadata['min_stitch_len_mm'] + 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']) + + layer = render_stitch_plan(self.svg, stitch_plan, True, visual_commands=False, render_jumps=False) + + write_png_output(self.svg, layer) + + # don't let inkex output the SVG! + sys.exit(0) -- cgit v1.2.3