summaryrefslogtreecommitdiff
path: root/lib/threads/color.py
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2018-06-09 21:35:25 -0400
committerGitHub <noreply@github.com>2018-06-09 21:35:25 -0400
commitae940b2466a79b2acc6de5eb33cffb8f7753c701 (patch)
tree5c060aecf2fe345d139387bea4084532acc5c72a /lib/threads/color.py
parent1c595c9003d66f49025fa67af838cbdba751449b (diff)
parentb36508bb53512a11dafbc3ecb16944045d88a52a (diff)
Merge pull request #187 from lexelby/lexelby-realistic-rendering
realistic rendering
Diffstat (limited to 'lib/threads/color.py')
-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)