From 2235ec6571601e12be7eb3c74907668fb68bebd4 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Fri, 11 Jul 2025 22:14:52 +0200 Subject: Fix issue with bad color names (#3816) * fix issue with bad color names and define element colors at one place and reuse * fix bad tartan color * verify color in gradient block * add thread color tests * use default color behavior for elements linked to non-existing definitions (gradients) * Added mypy change for tests (authored by: CapellanCitizen) --- lib/elements/fill_stitch.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/elements/fill_stitch.py') diff --git a/lib/elements/fill_stitch.py b/lib/elements/fill_stitch.py index 555c7e09..7ce3188a 100644 --- a/lib/elements/fill_stitch.py +++ b/lib/elements/fill_stitch.py @@ -7,7 +7,7 @@ import math import re import numpy as np -from inkex import LinearGradient +from inkex import Color, ColorError, LinearGradient from shapely import geometry as shgeo from shapely import set_precision from shapely.errors import GEOSException @@ -632,14 +632,12 @@ class FillStitch(EmbroideryElement): @property def color(self): - # SVG spec says the default fill is black - return self.get_style("fill", "#000000") + return self.fill_color @property def gradient(self): - gradient = self.node.get_computed_style("fill") - if isinstance(gradient, LinearGradient): - return gradient + if isinstance(self.fill_color, LinearGradient): + return self.fill_color return None @property @@ -1032,7 +1030,10 @@ class FillStitch(EmbroideryElement): def do_underlay(self, shape, starting_point): color = self.color if self.gradient is not None and self.fill_method == 'linear_gradient_fill': - color = self.gradient.stops[0].get_computed_style('stop-color') + try: + color = self.gradient.stops[0].get_computed_style('stop-color') + except ColorError: + color = Color('black') stitch_groups = [] for i in range(len(self.fill_underlay_angle)): -- cgit v1.2.3