summaryrefslogtreecommitdiff
path: root/lib/elements/fill_stitch.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2025-07-11 22:14:52 +0200
committerGitHub <noreply@github.com>2025-07-11 22:14:52 +0200
commit2235ec6571601e12be7eb3c74907668fb68bebd4 (patch)
tree61d85cb615a1b2327283e89f09592e1eb85ad91c /lib/elements/fill_stitch.py
parent7bd72274780ccaeae8bbae6e761341079df21ecb (diff)
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)
Diffstat (limited to 'lib/elements/fill_stitch.py')
-rw-r--r--lib/elements/fill_stitch.py15
1 files changed, 8 insertions, 7 deletions
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)):