From e52886a64a4e76c3fdc49df95c85655da3c4f7f4 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sun, 30 Jun 2024 22:49:18 +0200 Subject: Various fixes (#3028) * several thread palette extension fixes * fix svg tartan when original shape is invalid * tartan stroke spaces * style * fix tartan color substituion at pattern start * ripple: do not render too small paths * use less space for params warning headline * fix clone shape path * zip export template fix (typo) * add realistic stitch plan output warning (help tab) --- lib/extensions/apply_palette.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/extensions/apply_palette.py') diff --git a/lib/extensions/apply_palette.py b/lib/extensions/apply_palette.py index ce6c8f5c..cd8c4c94 100644 --- a/lib/extensions/apply_palette.py +++ b/lib/extensions/apply_palette.py @@ -3,7 +3,7 @@ # Copyright (c) 2024 Authors # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. -from ..elements import FillStitch +from ..elements import Clone, FillStitch from ..threads import ThreadCatalog, ThreadColor from .base import InkstitchExtension @@ -29,6 +29,16 @@ class ApplyPalette(InkstitchExtension): # Iterate through the color blocks to apply colors for element in self.elements: + if isinstance(element, Clone): + # clones use the color of their source element + continue + elif hasattr(element, 'gradient') and element.gradient is not None: + # apply colors to each gradient stop + for i, gradient_style in enumerate(element.gradient.stop_styles): + color = gradient_style['stop-color'] + gradient_style['stop-color'] = palette.nearest_color(ThreadColor(color)).to_hex_str() + continue + nearest_color = palette.nearest_color(ThreadColor(element.color)) if isinstance(element, FillStitch): element.node.style['fill'] = nearest_color.to_hex_str() -- cgit v1.2.3