|
|
|
@ -20,8 +20,7 @@
|
|
|
|
|
Charts styling |
|
|
|
|
""" |
|
|
|
|
from __future__ import division |
|
|
|
|
from pygal.util import cycle_fill |
|
|
|
|
from colorsys import rgb_to_hls, hls_to_rgb |
|
|
|
|
from pygal.util import cycle_fill, rgb_to_hsl, hsl_to_rgb |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def darken(color, percent): |
|
|
|
@ -30,15 +29,10 @@ def darken(color, percent):
|
|
|
|
|
assert len(color) in (3, 6), '#rrggbb and #rgb format are supported' |
|
|
|
|
if len(color) == 3: |
|
|
|
|
color = [a for b in zip(color, color) for a in b] |
|
|
|
|
|
|
|
|
|
return '#%02x%02x%02x' % tuple( |
|
|
|
|
map(lambda x: 255 * x, |
|
|
|
|
hls_to_rgb(*( |
|
|
|
|
lambda h, l, s: (h, max(0, min(1, l - percent / 100)), s))( |
|
|
|
|
*rgb_to_hls(*map( |
|
|
|
|
lambda x: int(''.join(x), 16) / 255, |
|
|
|
|
zip(color[::2], color[1::2]))) |
|
|
|
|
)))) |
|
|
|
|
return '#%02x%02x%02x' % hsl_to_rgb( |
|
|
|
|
*(lambda h, s, l: (h, s, max(0, min(100, l - percent))))( |
|
|
|
|
*rgb_to_hsl(*map(lambda x: int(''.join(x), 16), |
|
|
|
|
zip(color[::2], color[1::2]))))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def lighten(color, percent): |
|
|
|
|