website module: minor updates
This commit is contained in:
parent
93da8a1b0e
commit
1ffaaf4110
@ -309,9 +309,6 @@ def url_for_website(url):
|
|||||||
return url
|
return url
|
||||||
|
|
||||||
def get_hex_shade(color, percent):
|
def get_hex_shade(color, percent):
|
||||||
# stronger diff for darker shades
|
|
||||||
if int(color, 16) < int("333333", 16):
|
|
||||||
percent = percent * 2
|
|
||||||
|
|
||||||
def p(c):
|
def p(c):
|
||||||
v = int(c, 16) + int(int('ff', 16) * (float(percent)/100))
|
v = int(c, 16) + int(int('ff', 16) * (float(percent)/100))
|
||||||
@ -326,9 +323,14 @@ def get_hex_shade(color, percent):
|
|||||||
|
|
||||||
r, g, b = color[0:2], color[2:4], color[4:6]
|
r, g, b = color[0:2], color[2:4], color[4:6]
|
||||||
|
|
||||||
# switch dark and light shades
|
avg = (float(int(r, 16) + int(g, 16) + int(b, 16)) / 3)
|
||||||
if (float(int(r, 16) + int(g, 16) + int(b, 16)) / 3) > 128:
|
# switch dark and light shades
|
||||||
|
if avg > 128:
|
||||||
percent = -percent
|
percent = -percent
|
||||||
|
|
||||||
|
# stronger diff for darker shades
|
||||||
|
if percent < 25 and avg < 64:
|
||||||
|
percent = percent * 2
|
||||||
|
|
||||||
return p(r) + p(g) + p(b)
|
return p(r) + p(g) + p(b)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user