summaryrefslogtreecommitdiff
path: root/lib/extensions/apply_palette.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2024-06-30 22:49:18 +0200
committerGitHub <noreply@github.com>2024-06-30 22:49:18 +0200
commite52886a64a4e76c3fdc49df95c85655da3c4f7f4 (patch)
tree88a4edee630df0947553ced79fb6eb9dc510ccea /lib/extensions/apply_palette.py
parent7c06dee44ac7951a5db406eb829100a5bc3e5887 (diff)
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)
Diffstat (limited to 'lib/extensions/apply_palette.py')
-rw-r--r--lib/extensions/apply_palette.py12
1 files changed, 11 insertions, 1 deletions
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()