diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2020-05-15 14:56:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-15 14:56:02 +0200 |
| commit | 8695198e2181d157f526a990dac61841f8d16d7d (patch) | |
| tree | 96b2a38cfd1ec70d0f59d4017df731f3b2de4a76 /lib/threads | |
| parent | d9c61f4f3f6dd3e6f99b6df6eded14b7c3c48c35 (diff) | |
parse unicode color names (#686)
Diffstat (limited to 'lib/threads')
| -rw-r--r-- | lib/threads/color.py | 8 |
1 files changed, 7 insertions, 1 deletions
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): |
