added shades to website style

This commit is contained in:
Rushabh Mehta
2013-03-13 12:50:08 +05:30
parent 2eddd8ad68
commit 860f3ceada
3 changed files with 93 additions and 26 deletions

View File

@@ -302,4 +302,27 @@ def url_for_website(url):
if url and not url.lower().startswith("http"):
return "files/" + url
else:
return url
return url
def get_hex_shade(color, percent):
# switch dark and light shades
if int(color, 16) > int("808080", 16):
percent = -percent
# stronger diff for darker shades
if int(color, 16) < int("333333", 16):
percent = percent * 2
def p(c):
v = int(c, 16) + int(int('ff', 16) * (float(percent)/100))
if v < 0:
v=0
if v > 255:
v=255
h = hex(v)[2:]
if len(h) < 2:
h = "0" + h
return h
r, g, b = color[0:2], color[2:4], color[4:6]
return p(r) + p(g) + p(b)