From 8695198e2181d157f526a990dac61841f8d16d7d Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Fri, 15 May 2020 14:56:02 +0200 Subject: parse unicode color names (#686) --- lib/threads/color.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/threads') diff --git a/lib/threads/color.py b/lib/threads/color.py index ea9dab06..e24856a9 100644 --- a/lib/threads/color.py +++ b/lib/threads/color.py @@ -1,8 +1,10 @@ import colorsys -from pyembroidery.EmbThread import EmbThread import re +import tinycss2.color3 + import simplestyle +from pyembroidery.EmbThread import EmbThread class ThreadColor(object): @@ -17,6 +19,10 @@ class ThreadColor(object): self.manufacturer = color.brand self.rgb = (color.get_red(), color.get_green(), color.get_blue()) return + elif isinstance(color, unicode): + self.rgb = tinycss2.color3.parse_color(color) + # remove alpha channel and multiply with 255 + self.rgb = tuple(channel * 255.0 for channel in list(self.rgb)[:-1]) elif isinstance(color, (list, tuple)): self.rgb = tuple(color) elif self.hex_str_re.match(color): -- cgit v1.2.3