summaryrefslogtreecommitdiff
path: root/lib/threads/color.py
diff options
context:
space:
mode:
authorGeorge Steel <george.steel@gmail.com>2023-01-07 19:27:35 -0500
committerGeorge Steel <george.steel@gmail.com>2023-01-07 19:27:35 -0500
commitf69bd1654ae344b0f81f2caea6ef58846eb6e866 (patch)
tree8392ef0900ad8308a9819654cf6f5c0f8f40ab61 /lib/threads/color.py
parentd416407f2bb447a655266ae926337be853e88217 (diff)
parenta7b2122d91703d72177cf980cecbef8fca3d54ec (diff)
Merge branch 'main' of https://github.com/inkstitch/inkstitch into george-steel/random-base-satin
Diffstat (limited to 'lib/threads/color.py')
-rw-r--r--lib/threads/color.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/threads/color.py b/lib/threads/color.py
index 458752da..8dc1ea01 100644
--- a/lib/threads/color.py
+++ b/lib/threads/color.py
@@ -15,7 +15,7 @@ from inkex import Color
class ThreadColor(object):
hex_str_re = re.compile('#([0-9a-z]{3}|[0-9a-z]{6})', re.I)
- def __init__(self, color, name=None, number=None, manufacturer=None):
+ def __init__(self, color, name=None, number=None, manufacturer=None, description=None, chart=None):
# set colors with a gradient to black (avoiding an error message)
if type(color) == str and color.startswith('url'):
color = None
@@ -26,6 +26,8 @@ class ThreadColor(object):
self.name = color.description
self.number = color.catalog_number
self.manufacturer = color.brand
+ self.description = color.description
+ self.chart = color.chart
self.rgb = (color.get_red(), color.get_green(), color.get_blue())
return
elif isinstance(color, str):
@@ -42,6 +44,8 @@ class ThreadColor(object):
self.name = name
self.number = number
self.manufacturer = manufacturer
+ self.description = description
+ self.chart = chart
def __json__(self):
jsonified = self._as_dict()
@@ -53,6 +57,8 @@ class ThreadColor(object):
return dict(name=self.name,
number=self.number,
manufacturer=self.manufacturer,
+ description=self.description,
+ chart=self.chart,
rgb=self.rgb,
hex=self.to_hex_str(),
)
@@ -81,6 +87,8 @@ class ThreadColor(object):
"name": self.name,
"id": self.number,
"manufacturer": self.manufacturer,
+ "description": self.description,
+ "chart": self.chart,
"rgb": int(self.hex_digits, 16),
}
@@ -125,7 +133,7 @@ class ThreadColor(object):
# convert back to values in the range of 0-255
color = tuple(value * 255 for value in color)
- return ThreadColor(color, name=self.name, number=self.number, manufacturer=self.manufacturer)
+ return ThreadColor(color, name=self.name, number=self.number, manufacturer=self.manufacturer, description=self.description, chart=self.chart)
@property
def darker(self):
@@ -140,4 +148,4 @@ class ThreadColor(object):
# convert back to values in the range of 0-255
color = tuple(value * 255 for value in color)
- return ThreadColor(color, name=self.name, number=self.number, manufacturer=self.manufacturer)
+ return ThreadColor(color, name=self.name, number=self.number, manufacturer=self.manufacturer, description=self.description, chart=self.chart)