]> de.git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Cap RGB value darkness by first converting to HSL, then applying threshold.
authorAnt Zucaro <azucaro@gmail.com>
Sun, 18 Mar 2012 20:07:03 +0000 (16:07 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Sun, 18 Mar 2012 20:07:03 +0000 (16:07 -0400)
RGB values that were too dark to read against a black background are now viewable. This is done by converting the RGB values (from the hex values provided) to HSL, then moving any L (lightness) values beyond a certain threshold back. Finally they are converted back to RGB for display. In practice all this really does is to lighten the dark colors without changing their hue or saturation values (e.g. black becomes gray).

Thanks go to dmazary for helping me with this and working through the various bugs I found. Thanks, Dave!

xonstat/util.py

index de5153a485069860eb070d09efe022fad6f9e56b..1db7770565314029da3a2b8734a22d75513d6063 100755 (executable)
@@ -42,16 +42,16 @@ _qfont_table = [
 
 # Hex-colored spans for decimal color codes ^0 - ^9
 _dec_spans = [
- "<span style='color:#333333'>",
- "<span style='color:#FF0000'>",
- "<span style='color:#33FF00'>",
- "<span style='color:#FFFF00'>",
- "<span style='color:#3366FF'>",
- "<span style='color:#33FFFF'>",
- "<span style='color:#FF3366'>",
- "<span style='color:#FFFFFF'>",
- "<span style='color:#999999'>",
- "<span style='color:#666666'>"
+ "<span style='color:rgb(128,128,128)'>",
+ "<span style='color:rgb(255,0,0)'>",
+ "<span style='color:rgb(51,255,0)'>",
+ "<span style='color:rgb(255,255,0)'>",
+ "<span style='color:rgb(51,102,255)'>",
+ "<span style='color:rgb(51,255,255)'>",
+ "<span style='color:rgb(255,51,102)'>",
+ "<span style='color:rgb(255,255,255)'>",
+ "<span style='color:rgb(153,153,153)'>",
+ "<span style='color:rgb(128,128,128)'>"
 ]
 
 # Color code patterns