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