mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-04 14:08:29 +00:00
added shades to website style
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user