Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2011-05-17 16:33:34 (GMT)
committer Walter Bender <walter.bender@gmail.com>2011-05-17 16:33:34 (GMT)
commit88b80c145bc8b83b9ef6bcd39193b5331f5556bc (patch)
treecae0266f19c77a5dd0f98d22c06d42ee2584ffd5
parent86996bb6a36241596a7699224580301a6a4fbe2d (diff)
fixed bug in parsing colors during luminance calculation
-rw-r--r--utils.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/utils.py b/utils.py
index 75438d7..652999a 100644
--- a/utils.py
+++ b/utils.py
@@ -32,12 +32,13 @@ def get_path(activity, subpath):
def _luminance(color):
''' Calculate luminance value '''
- return int(color[0:2], 16) * 0.3 + int(color[2:4], 16) * 0.6 + int(color[4:6]) * 0.1
+ return int(color[1:3], 16) * 0.3 + int(color[3:5], 16) * 0.6 + \
+ int(color[5:7], 16) * 0.1
def lighter_color(colors):
''' Which color is lighter? Use that one for the text background '''
- if _luminance(colors[0][1:6]) > _luminance(colors[1][1:6]):
+ if _luminance(colors[0]) > _luminance(colors[1]):
return 0
return 1