summaryrefslogtreecommitdiff
path: root/lib/threads
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2018-05-26 21:26:40 -0400
committerLex Neva <github.com@lexneva.name>2018-05-29 20:04:30 -0400
commit4c986117bfe1f2caa8280d4b0ddbeec69f41b18d (patch)
tree76e076b6bc1e331d63252ff30917f0475f24c962 /lib/threads
parentd50c7e1b99b570ec5300de39c2966ac864700138 (diff)
first attempt at realistic rendering
Diffstat (limited to 'lib/threads')
-rw-r--r--lib/threads/color.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/threads/color.py b/lib/threads/color.py
index af474127..fede2ecc 100644
--- a/lib/threads/color.py
+++ b/lib/threads/color.py
@@ -80,3 +80,18 @@ class ThreadColor(object):
color = tuple(value * 255 for value in color)
return ThreadColor(color, name=self.name, number=self.number, manufacturer=self.manufacturer)
+
+ @property
+ def darker(self):
+ hls = list(colorsys.rgb_to_hls(*self.rgb_normalized))
+
+ # Capping lightness should make the color visible without changing it
+ # too much.
+ hls[1] *= 0.75
+
+ color = colorsys.hls_to_rgb(*hls)
+
+ # 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)