summaryrefslogtreecommitdiffstats
path: root/Tools/pynche
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1998-09-28 23:39:18 (GMT)
committerBarry Warsaw <barry@python.org>1998-09-28 23:39:18 (GMT)
commit0e3e6991787f869a684066bc54c58f29cd7f1c9f (patch)
treefd2a8cad80678e737628e322d68dd5f45ecc42ba /Tools/pynche
parenta69c1ba0aaa4c02a1c14c6f5ce0833cb493c9bfa (diff)
downloadcpython-0e3e6991787f869a684066bc54c58f29cd7f1c9f.zip
cpython-0e3e6991787f869a684066bc54c58f29cd7f1c9f.tar.gz
cpython-0e3e6991787f869a684066bc54c58f29cd7f1c9f.tar.bz2
triplet_to_brightness(): New function
Diffstat (limited to 'Tools/pynche')
-rw-r--r--Tools/pynche/ColorDB.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Tools/pynche/ColorDB.py b/Tools/pynche/ColorDB.py
index fae0a3b..a4c8342 100644
--- a/Tools/pynche/ColorDB.py
+++ b/Tools/pynche/ColorDB.py
@@ -174,6 +174,15 @@ def triplet_to_fractional_rgb(rgbtuple):
return map(operator.__div__, rgbtuple, _maxtuple)
+def triplet_to_brightness(rgbtuple):
+ # return the brightness (grey level) along the scale 0.0==black to
+ # 1.0==white
+ r = 0.299
+ g = 0.587
+ b = 0.114
+ return r*rgbtuple[0] + g*rgbtuple[1] + b*rgbtuple[2]
+
+
if __name__ == '__main__':
import string