Skip to content

Commit

Permalink
create news theme color -> bluestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
Anaèle Digoin committed Jun 19, 2013
1 parent 563456f commit 54c4b88
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion pygal/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@
"""
from __future__ import division
from pygal.util import cycle_fill
from colorsys import rgb_to_hls, hls_to_rgb


def darken(color, percent):
assert color[0] == '#', '#rrggbb and #rgb format are supported'
color = color[1:]
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])))
))))


def lighten(color, percent):
return darken(color, -percent)


class Style(object):
Expand Down Expand Up @@ -217,6 +239,18 @@ def to_dict(self):
colors=(lighten('#34B8F7', 15), '#7dcf30', '#247fab', darken('#7dcf30', 10),
lighten('#247fab', 10), lighten('#7dcf30', 10), darken('#247fab', 10), '#fff'))

BlueStyle = Style(
background=darken('#f8f8f8', 3),
plot_background='#f8f8f8',
foreground='rgba(0, 0, 0, 0.9)',
foreground_light='rgba(0, 0, 0, 0.9)',
foreground_dark='rgba(0, 0, 0, 0.6)',
opacity='.5',
opacity_hover='.9',
transition='250ms ease-in',
colors=('#00b2f0', '#43d9be', '#0662ab', '#ffd541', lighten('#43d9be', 20),
lighten('#7dcf30', 10), darken('#0662ab', 15), '#7dcf30', darken('#ffd541', 20)))

styles = {'default': DefaultStyle,
'light': LightStyle,
'neon': NeonStyle,
Expand All @@ -229,4 +263,5 @@ def to_dict(self):
'turquoise': TurquoiseStyle,
'green': GreenLightStyle,
'dark_green': GreenDarkStyle,
'dark_green_blue': GreenBlueDarkStyle}
'dark_green_blue': GreenBlueDarkStyle,
'blue_colorized': BlueStyle}

0 comments on commit 54c4b88

Please sign in to comment.