|
|
@ -22,41 +22,48 @@ from __future__ import division |
|
|
|
from pygal.util import cycle_fill |
|
|
|
from pygal.util import cycle_fill |
|
|
|
from pygal import colors |
|
|
|
from pygal import colors |
|
|
|
from pygal.colors import darken, lighten |
|
|
|
from pygal.colors import darken, lighten |
|
|
|
import sys |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Style(object): |
|
|
|
class Style(object): |
|
|
|
|
|
|
|
|
|
|
|
"""Styling class containing colors for the css generation""" |
|
|
|
"""Styling class containing colors for the css generation""" |
|
|
|
|
|
|
|
|
|
|
|
def __init__( |
|
|
|
plot_background = 'rgba(255, 255, 255, 1)' |
|
|
|
self, |
|
|
|
background = 'rgba(249, 249, 249, 1)' |
|
|
|
background='black', |
|
|
|
foreground = 'rgba(0, 0, 0, .87)' |
|
|
|
plot_background='#111', |
|
|
|
foreground_strong = 'rgba(0, 0, 0, 1)' |
|
|
|
foreground='#999', |
|
|
|
foreground_subtle = 'rgba(0, 0, 0, .54)' |
|
|
|
foreground_light='#eee', |
|
|
|
# Monospaced font is highly encouraged |
|
|
|
foreground_dark='#555', |
|
|
|
font_family = 'Consolas, "Liberation Mono", Menlo, Courier, ' |
|
|
|
font_family='monospace', # Monospaced font is highly encouraged |
|
|
|
'monospace' |
|
|
|
opacity='.8', |
|
|
|
opacity = '.7' |
|
|
|
opacity_hover='.9', |
|
|
|
opacity_hover = '.8' |
|
|
|
transition='250ms', |
|
|
|
transition = '150ms' |
|
|
|
colors=( |
|
|
|
colors = ( |
|
|
|
'#ff5995', '#b6e354', '#feed6c', '#8cedff', '#9e6ffe', |
|
|
|
'#F44336', # 0 |
|
|
|
|
|
|
|
'#3F51B5', # 4 |
|
|
|
'#899ca1', '#f8f8f2', '#bf4646', '#516083', '#f92672', |
|
|
|
'#009688', # 8 |
|
|
|
'#82b414', '#fd971f', '#56c2d6', '#808384', '#8c54fe', |
|
|
|
'#FFC107', # 13 |
|
|
|
'#465457')): |
|
|
|
'#FF5722', # 15 |
|
|
|
|
|
|
|
'#9C27B0', # 2 |
|
|
|
|
|
|
|
'#03A9F4', # 6 |
|
|
|
|
|
|
|
'#8BC34A', # 10 |
|
|
|
|
|
|
|
'#FF9800', # 14 |
|
|
|
|
|
|
|
'#E91E63', # 1 |
|
|
|
|
|
|
|
'#2196F3', # 5 |
|
|
|
|
|
|
|
'#4CAF50', # 9 |
|
|
|
|
|
|
|
'#FFEB3B', # 12 |
|
|
|
|
|
|
|
'#673AB7', # 3 |
|
|
|
|
|
|
|
'#00BCD4', # 7 |
|
|
|
|
|
|
|
'#CDDC39', # 11 |
|
|
|
|
|
|
|
'#795548', # 16 |
|
|
|
|
|
|
|
'#9E9E9E', # 17 |
|
|
|
|
|
|
|
'#607D8B', # 18 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, **kwargs): |
|
|
|
"""Create the style""" |
|
|
|
"""Create the style""" |
|
|
|
self.background = background |
|
|
|
self.__dict__.update(kwargs) |
|
|
|
self.plot_background = plot_background |
|
|
|
|
|
|
|
self.foreground = foreground |
|
|
|
|
|
|
|
self.foreground_light = foreground_light |
|
|
|
|
|
|
|
self.foreground_dark = foreground_dark |
|
|
|
|
|
|
|
self.font_family = font_family |
|
|
|
|
|
|
|
self.opacity = opacity |
|
|
|
|
|
|
|
self.opacity_hover = opacity_hover |
|
|
|
|
|
|
|
self.transition = transition |
|
|
|
|
|
|
|
self.colors = colors |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_colors(self, prefix, len_): |
|
|
|
def get_colors(self, prefix, len_): |
|
|
|
"""Get the css color list""" |
|
|
|
"""Get the css color list""" |
|
|
@ -86,194 +93,249 @@ class Style(object): |
|
|
|
return config |
|
|
|
return config |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DefaultStyle = Style(opacity_hover='.4', opacity='.8') |
|
|
|
DefaultStyle = Style |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LightStyle = Style( |
|
|
|
class DarkStyle(Style): |
|
|
|
background='white', |
|
|
|
|
|
|
|
plot_background='rgba(0, 0, 255, 0.1)', |
|
|
|
|
|
|
|
foreground='rgba(0, 0, 0, 0.7)', |
|
|
|
|
|
|
|
foreground_light='rgba(0, 0, 0, 0.9)', |
|
|
|
|
|
|
|
foreground_dark='rgba(0, 0, 0, 0.5)', |
|
|
|
|
|
|
|
colors=('#242424', '#9f6767', '#92ac68', |
|
|
|
|
|
|
|
'#d0d293', '#9aacc3', '#bb77a4', |
|
|
|
|
|
|
|
'#77bbb5', '#777777')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""A dark style (old default)""" |
|
|
|
|
|
|
|
|
|
|
|
NeonStyle = Style( |
|
|
|
background = 'black' |
|
|
|
opacity='.1', |
|
|
|
plot_background = '#111' |
|
|
|
opacity_hover='.75', |
|
|
|
foreground = '#999' |
|
|
|
transition='1s ease-out') |
|
|
|
foreground_strong = '#eee' |
|
|
|
|
|
|
|
foreground_subtle = '#555' |
|
|
|
|
|
|
|
opacity = '.8' |
|
|
|
|
|
|
|
opacity_hover = '.4' |
|
|
|
|
|
|
|
transition = '250ms' |
|
|
|
|
|
|
|
colors = ( |
|
|
|
|
|
|
|
'#ff5995', '#b6e354', '#feed6c', '#8cedff', '#9e6ffe', |
|
|
|
|
|
|
|
'#899ca1', '#f8f8f2', '#bf4646', '#516083', '#f92672', |
|
|
|
|
|
|
|
'#82b414', '#fd971f', '#56c2d6', '#808384', '#8c54fe', |
|
|
|
|
|
|
|
'#465457') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CleanStyle = Style( |
|
|
|
class LightStyle(Style): |
|
|
|
background='transparent', |
|
|
|
|
|
|
|
plot_background='rgba(240, 240, 240, 0.7)', |
|
|
|
"""A light style""" |
|
|
|
foreground='rgba(0, 0, 0, 0.9)', |
|
|
|
|
|
|
|
foreground_light='rgba(0, 0, 0, 0.9)', |
|
|
|
background = 'white' |
|
|
|
foreground_dark='rgba(0, 0, 0, 0.5)', |
|
|
|
plot_background = 'rgba(0, 0, 255, 0.1)' |
|
|
|
colors=( |
|
|
|
foreground = 'rgba(0, 0, 0, 0.7)' |
|
|
|
|
|
|
|
foreground_strong = 'rgba(0, 0, 0, 0.9)' |
|
|
|
|
|
|
|
foreground_subtle = 'rgba(0, 0, 0, 0.5)' |
|
|
|
|
|
|
|
colors = ('#242424', '#9f6767', '#92ac68', |
|
|
|
|
|
|
|
'#d0d293', '#9aacc3', '#bb77a4', |
|
|
|
|
|
|
|
'#77bbb5', '#777777') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NeonStyle(DarkStyle): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""Similar to DarkStyle but with more opacity and effects""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
opacity = '.1' |
|
|
|
|
|
|
|
opacity_hover = '.75' |
|
|
|
|
|
|
|
transition = '1s ease-out' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CleanStyle(Style): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""A rather clean style""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
background = 'transparent' |
|
|
|
|
|
|
|
plot_background = 'rgba(240, 240, 240, 0.7)' |
|
|
|
|
|
|
|
foreground = 'rgba(0, 0, 0, 0.9)' |
|
|
|
|
|
|
|
foreground_strong = 'rgba(0, 0, 0, 0.9)' |
|
|
|
|
|
|
|
foreground_subtle = 'rgba(0, 0, 0, 0.5)' |
|
|
|
|
|
|
|
colors = ( |
|
|
|
'rgb(12,55,149)', 'rgb(117,38,65)', 'rgb(228,127,0)', 'rgb(159,170,0)', |
|
|
|
'rgb(12,55,149)', 'rgb(117,38,65)', 'rgb(228,127,0)', 'rgb(159,170,0)', |
|
|
|
'rgb(149,12,12)')) |
|
|
|
'rgb(149,12,12)') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
solarized_colors = ( |
|
|
|
class DarkSolarizedStyle(Style): |
|
|
|
'#b58900', '#cb4b16', '#dc322f', '#d33682', |
|
|
|
|
|
|
|
'#6c71c4', '#268bd2', '#2aa198', '#859900') |
|
|
|
"""Dark solarized popular theme""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
background = '#073642' |
|
|
|
DarkSolarizedStyle = Style( |
|
|
|
plot_background = '#002b36' |
|
|
|
background='#073642', |
|
|
|
foreground = '#839496' |
|
|
|
plot_background='#002b36', |
|
|
|
foreground_strong = '#fdf6e3' |
|
|
|
foreground='#839496', |
|
|
|
foreground_subtle = '#657b83' |
|
|
|
foreground_light='#fdf6e3', |
|
|
|
opacity = '.66' |
|
|
|
foreground_dark='#657b83', |
|
|
|
opacity_hover = '.9' |
|
|
|
opacity='.66', |
|
|
|
transition = '500ms ease-in' |
|
|
|
opacity_hover='.9', |
|
|
|
colors = ( |
|
|
|
transition='500ms ease-in', |
|
|
|
'#b58900', '#cb4b16', '#dc322f', '#d33682', |
|
|
|
colors=solarized_colors) |
|
|
|
'#6c71c4', '#268bd2', '#2aa198', '#859900') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LightSolarizedStyle = Style( |
|
|
|
class LightSolarizedStyle(DarkSolarizedStyle): |
|
|
|
background='#fdf6e3', |
|
|
|
|
|
|
|
plot_background='#eee8d5', |
|
|
|
"""Light solarized popular theme""" |
|
|
|
foreground='#657b83', |
|
|
|
|
|
|
|
foreground_light='#073642', |
|
|
|
background = '#fdf6e3' |
|
|
|
foreground_dark='#073642', |
|
|
|
plot_background = '#eee8d5' |
|
|
|
opacity='.6', |
|
|
|
foreground = '#657b83' |
|
|
|
opacity_hover='.9', |
|
|
|
foreground_strong = '#073642' |
|
|
|
transition='500ms ease-in', |
|
|
|
foreground_subtle = '#073642' |
|
|
|
colors=solarized_colors) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RedBlueStyle(Style): |
|
|
|
RedBlueStyle = Style( |
|
|
|
|
|
|
|
background=lighten('#e6e7e9', 7), |
|
|
|
"""A red and blue theme""" |
|
|
|
plot_background=lighten('#e6e7e9', 10), |
|
|
|
|
|
|
|
foreground='rgba(0, 0, 0, 0.9)', |
|
|
|
background = lighten('#e6e7e9', 7) |
|
|
|
foreground_light='rgba(0, 0, 0, 0.9)', |
|
|
|
plot_background = lighten('#e6e7e9', 10) |
|
|
|
foreground_dark='rgba(0, 0, 0, 0.5)', |
|
|
|
foreground = 'rgba(0, 0, 0, 0.9)' |
|
|
|
opacity='.6', |
|
|
|
foreground_strong = 'rgba(0, 0, 0, 0.9)' |
|
|
|
opacity_hover='.9', |
|
|
|
foreground_subtle = 'rgba(0, 0, 0, 0.5)' |
|
|
|
colors=( |
|
|
|
opacity = '.6' |
|
|
|
|
|
|
|
opacity_hover = '.9' |
|
|
|
|
|
|
|
colors = ( |
|
|
|
'#d94e4c', '#e5884f', '#39929a', |
|
|
|
'#d94e4c', '#e5884f', '#39929a', |
|
|
|
lighten('#d94e4c', 10), darken('#39929a', 15), lighten('#e5884f', 17), |
|
|
|
lighten('#d94e4c', 10), darken('#39929a', 15), lighten('#e5884f', 17), |
|
|
|
darken('#d94e4c', 10), '#234547')) |
|
|
|
darken('#d94e4c', 10), '#234547') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LightColorizedStyle = Style( |
|
|
|
class LightColorizedStyle(Style): |
|
|
|
background='#f8f8f8', |
|
|
|
|
|
|
|
plot_background=lighten('#f8f8f8', 3), |
|
|
|
"""A light colorized style""" |
|
|
|
foreground='#333', |
|
|
|
|
|
|
|
foreground_light='#666', |
|
|
|
background = '#f8f8f8' |
|
|
|
foreground_dark='rgba(0, 0 , 0, 0.5)', |
|
|
|
plot_background = lighten('#f8f8f8', 3) |
|
|
|
opacity='.5', |
|
|
|
foreground = '#333' |
|
|
|
opacity_hover='.9', |
|
|
|
foreground_strong = '#666' |
|
|
|
transition='250ms ease-in', |
|
|
|
foreground_subtle = 'rgba(0, 0 , 0, 0.5)' |
|
|
|
colors=( |
|
|
|
opacity = '.5' |
|
|
|
|
|
|
|
opacity_hover = '.9' |
|
|
|
|
|
|
|
transition = '250ms ease-in' |
|
|
|
|
|
|
|
colors = ( |
|
|
|
'#fe9592', '#534f4c', '#3ac2c0', '#a2a7a1', |
|
|
|
'#fe9592', '#534f4c', '#3ac2c0', '#a2a7a1', |
|
|
|
darken('#fe9592', 15), lighten('#534f4c', 15), lighten('#3ac2c0', 15), |
|
|
|
darken('#fe9592', 15), lighten('#534f4c', 15), lighten('#3ac2c0', 15), |
|
|
|
lighten('#a2a7a1', 15), lighten('#fe9592', 15), darken('#3ac2c0', 10))) |
|
|
|
lighten('#a2a7a1', 15), lighten('#fe9592', 15), darken('#3ac2c0', 10)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DarkColorizedStyle = Style( |
|
|
|
class DarkColorizedStyle(Style): |
|
|
|
background=darken('#3a2d3f', 5), |
|
|
|
|
|
|
|
plot_background=lighten('#3a2d3f', 2), |
|
|
|
"""A dark colorized style""" |
|
|
|
foreground='rgba(255, 255, 255, 0.9)', |
|
|
|
|
|
|
|
foreground_light='rgba(255, 255, 255, 0.9)', |
|
|
|
background = darken('#3a2d3f', 5) |
|
|
|
foreground_dark='rgba(255, 255 , 255, 0.5)', |
|
|
|
plot_background = lighten('#3a2d3f', 2) |
|
|
|
opacity='.2', |
|
|
|
foreground = 'rgba(255, 255, 255, 0.9)' |
|
|
|
opacity_hover='.7', |
|
|
|
foreground_strong = 'rgba(255, 255, 255, 0.9)' |
|
|
|
transition='250ms ease-in', |
|
|
|
foreground_subtle = 'rgba(255, 255 , 255, 0.5)' |
|
|
|
colors=( |
|
|
|
opacity = '.2' |
|
|
|
|
|
|
|
opacity_hover = '.7' |
|
|
|
|
|
|
|
transition = '250ms ease-in' |
|
|
|
|
|
|
|
colors = ( |
|
|
|
'#c900fe', '#01b8fe', '#59f500', '#ff00e4', '#f9fa00', |
|
|
|
'#c900fe', '#01b8fe', '#59f500', '#ff00e4', '#f9fa00', |
|
|
|
darken('#c900fe', 20), darken('#01b8fe', 15), darken('#59f500', 20), |
|
|
|
darken('#c900fe', 20), darken('#01b8fe', 15), darken('#59f500', 20), |
|
|
|
darken('#ff00e4', 15), lighten('#f9fa00', 20))) |
|
|
|
darken('#ff00e4', 15), lighten('#f9fa00', 20)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TurquoiseStyle = Style( |
|
|
|
class TurquoiseStyle(Style): |
|
|
|
background=darken('#1b8088', 15), |
|
|
|
|
|
|
|
plot_background=darken('#1b8088', 17), |
|
|
|
"""A turquoise style""" |
|
|
|
foreground='rgba(255, 255, 255, 0.9)', |
|
|
|
|
|
|
|
foreground_light='rgba(255, 255, 255, 0.9)', |
|
|
|
background = darken('#1b8088', 15) |
|
|
|
foreground_dark='rgba(255, 255 , 255, 0.5)', |
|
|
|
plot_background = darken('#1b8088', 17) |
|
|
|
opacity='.5', |
|
|
|
foreground = 'rgba(255, 255, 255, 0.9)' |
|
|
|
opacity_hover='.9', |
|
|
|
foreground_strong = 'rgba(255, 255, 255, 0.9)' |
|
|
|
transition='250ms ease-in', |
|
|
|
foreground_subtle = 'rgba(255, 255 , 255, 0.5)' |
|
|
|
colors=( |
|
|
|
opacity = '.5' |
|
|
|
|
|
|
|
opacity_hover = '.9' |
|
|
|
|
|
|
|
transition = '250ms ease-in' |
|
|
|
|
|
|
|
colors = ( |
|
|
|
'#93d2d9', '#ef940f', '#8C6243', '#fff', |
|
|
|
'#93d2d9', '#ef940f', '#8C6243', '#fff', |
|
|
|
darken('#93d2d9', 20), lighten('#ef940f', 15), |
|
|
|
darken('#93d2d9', 20), lighten('#ef940f', 15), |
|
|
|
lighten('#8c6243', 15), '#1b8088')) |
|
|
|
lighten('#8c6243', 15), '#1b8088') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LightGreenStyle = Style( |
|
|
|
class LightGreenStyle(Style): |
|
|
|
background=lighten('#f3f3f3', 3), |
|
|
|
|
|
|
|
plot_background='#fff', |
|
|
|
"""A light green style""" |
|
|
|
foreground='#333333', |
|
|
|
|
|
|
|
foreground_light='#666', |
|
|
|
background = lighten('#f3f3f3', 3) |
|
|
|
foreground_dark='#222222', |
|
|
|
plot_background = '#fff' |
|
|
|
opacity='.5', |
|
|
|
foreground = '#333333' |
|
|
|
opacity_hover='.9', |
|
|
|
foreground_strong = '#666' |
|
|
|
transition='250ms ease-in', |
|
|
|
foreground_subtle = '#222222' |
|
|
|
colors=( |
|
|
|
opacity = '.5' |
|
|
|
|
|
|
|
opacity_hover = '.9' |
|
|
|
|
|
|
|
transition = '250ms ease-in' |
|
|
|
|
|
|
|
colors = ( |
|
|
|
'#7dcf30', '#247fab', lighten('#7dcf30', 10), '#ccc', |
|
|
|
'#7dcf30', '#247fab', lighten('#7dcf30', 10), '#ccc', |
|
|
|
darken('#7dcf30', 15), '#ddd', lighten('#247fab', 10), |
|
|
|
darken('#7dcf30', 15), '#ddd', lighten('#247fab', 10), |
|
|
|
darken('#247fab', 15))) |
|
|
|
darken('#247fab', 15)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DarkGreenStyle = Style( |
|
|
|
class DarkGreenStyle(Style): |
|
|
|
background=darken('#251e01', 3), |
|
|
|
|
|
|
|
plot_background=darken('#251e01', 1), |
|
|
|
"""A dark green style""" |
|
|
|
foreground='rgba(255, 255, 255, 0.9)', |
|
|
|
|
|
|
|
foreground_light='rgba(255, 255, 255, 0.9)', |
|
|
|
background = darken('#251e01', 3) |
|
|
|
foreground_dark='rgba(255, 255, 255, 0.6)', |
|
|
|
plot_background = darken('#251e01', 1) |
|
|
|
opacity='.6', |
|
|
|
foreground = 'rgba(255, 255, 255, 0.9)' |
|
|
|
opacity_hover='.9', |
|
|
|
foreground_strong = 'rgba(255, 255, 255, 0.9)' |
|
|
|
transition='250ms ease-in', |
|
|
|
foreground_subtle = 'rgba(255, 255, 255, 0.6)' |
|
|
|
colors=( |
|
|
|
opacity = '.6' |
|
|
|
|
|
|
|
opacity_hover = '.9' |
|
|
|
|
|
|
|
transition = '250ms ease-in' |
|
|
|
|
|
|
|
colors = ( |
|
|
|
'#adde09', '#6e8c06', '#4a5e04', '#fcd202', '#C1E34D', |
|
|
|
'#adde09', '#6e8c06', '#4a5e04', '#fcd202', '#C1E34D', |
|
|
|
lighten('#fcd202', 25))) |
|
|
|
lighten('#fcd202', 25)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DarkGreenBlueStyle = Style( |
|
|
|
class DarkGreenBlueStyle(Style): |
|
|
|
background='#000', |
|
|
|
|
|
|
|
plot_background=lighten('#000', 8), |
|
|
|
"""A dark green and blue style""" |
|
|
|
foreground='rgba(255, 255, 255, 0.9)', |
|
|
|
|
|
|
|
foreground_light='rgba(255, 255, 255, 0.9)', |
|
|
|
background = '#000' |
|
|
|
foreground_dark='rgba(255, 255, 255, 0.6)', |
|
|
|
plot_background = lighten('#000', 8) |
|
|
|
opacity='.55', |
|
|
|
foreground = 'rgba(255, 255, 255, 0.9)' |
|
|
|
opacity_hover='.9', |
|
|
|
foreground_strong = 'rgba(255, 255, 255, 0.9)' |
|
|
|
transition='250ms ease-in', |
|
|
|
foreground_subtle = 'rgba(255, 255, 255, 0.6)' |
|
|
|
colors=(lighten('#34B8F7', 15), '#7dcf30', '#247fab', |
|
|
|
opacity = '.55' |
|
|
|
darken('#7dcf30', 10), lighten('#247fab', 10), |
|
|
|
opacity_hover = '.9' |
|
|
|
lighten('#7dcf30', 10), darken('#247fab', 10), '#fff')) |
|
|
|
transition = '250ms ease-in' |
|
|
|
|
|
|
|
colors = (lighten('#34B8F7', 15), '#7dcf30', '#247fab', |
|
|
|
|
|
|
|
darken('#7dcf30', 10), lighten('#247fab', 10), |
|
|
|
BlueStyle = Style( |
|
|
|
lighten('#7dcf30', 10), darken('#247fab', 10), '#fff') |
|
|
|
background=darken('#f8f8f8', 3), |
|
|
|
|
|
|
|
plot_background='#f8f8f8', |
|
|
|
|
|
|
|
foreground='rgba(0, 0, 0, 0.9)', |
|
|
|
class BlueStyle(Style): |
|
|
|
foreground_light='rgba(0, 0, 0, 0.9)', |
|
|
|
|
|
|
|
foreground_dark='rgba(0, 0, 0, 0.6)', |
|
|
|
"""A blue style""" |
|
|
|
opacity='.5', |
|
|
|
|
|
|
|
opacity_hover='.9', |
|
|
|
background = darken('#f8f8f8', 3) |
|
|
|
transition='250ms ease-in', |
|
|
|
plot_background = '#f8f8f8' |
|
|
|
colors=( |
|
|
|
foreground = 'rgba(0, 0, 0, 0.9)' |
|
|
|
|
|
|
|
foreground_strong = 'rgba(0, 0, 0, 0.9)' |
|
|
|
|
|
|
|
foreground_subtle = 'rgba(0, 0, 0, 0.6)' |
|
|
|
|
|
|
|
opacity = '.5' |
|
|
|
|
|
|
|
opacity_hover = '.9' |
|
|
|
|
|
|
|
transition = '250ms ease-in' |
|
|
|
|
|
|
|
colors = ( |
|
|
|
'#00b2f0', '#43d9be', '#0662ab', darken('#00b2f0', 20), |
|
|
|
'#00b2f0', '#43d9be', '#0662ab', darken('#00b2f0', 20), |
|
|
|
lighten('#43d9be', 20), lighten('#7dcf30', 10), darken('#0662ab', 15), |
|
|
|
lighten('#43d9be', 20), lighten('#7dcf30', 10), darken('#0662ab', 15), |
|
|
|
'#ffd541', '#7dcf30', lighten('#00b2f0', 15), darken('#ffd541', 20))) |
|
|
|
'#ffd541', '#7dcf30', lighten('#00b2f0', 15), darken('#ffd541', 20)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SolidColorStyle(Style): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""A light style with strong colors""" |
|
|
|
|
|
|
|
|
|
|
|
SolidColorStyle = Style( |
|
|
|
background = '#FFFFFF' |
|
|
|
background='#FFFFFF', |
|
|
|
plot_background = '#FFFFFF' |
|
|
|
plot_background='#FFFFFF', |
|
|
|
foreground = '#000000' |
|
|
|
foreground='#000000', |
|
|
|
foreground_strong = '#000000' |
|
|
|
foreground_light='#000000', |
|
|
|
foreground_subtle = '#828282' |
|
|
|
foreground_dark='#828282', |
|
|
|
opacity = '.8' |
|
|
|
opacity='.8', |
|
|
|
opacity_hover = '.9' |
|
|
|
opacity_hover='.9', |
|
|
|
transition = '400ms ease-in' |
|
|
|
transition='400ms ease-in', |
|
|
|
colors = ( |
|
|
|
colors=('#FF9900', '#DC3912', '#4674D1', '#109618', '#990099', |
|
|
|
'#FF9900', '#DC3912', '#4674D1', '#109618', '#990099', |
|
|
|
'#0099C6', '#DD4477', '#74B217', '#B82E2E', '#316395', '#994499')) |
|
|
|
'#0099C6', '#DD4477', '#74B217', '#B82E2E', '#316395', '#994499') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
styles = {'default': DefaultStyle, |
|
|
|
styles = {'default': DefaultStyle, |
|
|
@ -293,55 +355,92 @@ styles = {'default': DefaultStyle, |
|
|
|
'solid_color': SolidColorStyle} |
|
|
|
'solid_color': SolidColorStyle} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parametric_styles = {} |
|
|
|
class ParametricStyleBase(Style): |
|
|
|
for op in ('lighten', 'darken', 'saturate', 'desaturate', 'rotate'): |
|
|
|
|
|
|
|
name = op.capitalize() + 'Style' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_style_for(op_name): |
|
|
|
"""Parametric Style base class for all the parametric operations""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_op = None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, color, step=10, max_=None, base_style=None, **kwargs): |
|
|
|
""" |
|
|
|
""" |
|
|
|
Return a callable that returns a Style instance |
|
|
|
Initialization of the parametric style. |
|
|
|
for the given operation |
|
|
|
|
|
|
|
|
|
|
|
This takes several parameters: |
|
|
|
|
|
|
|
* a `step` which correspond on how many colors will be needed |
|
|
|
|
|
|
|
* a `max_` which defines the maximum amplitude of the color effect |
|
|
|
|
|
|
|
* a `base_style` which will be taken as default for everything |
|
|
|
|
|
|
|
except colors |
|
|
|
|
|
|
|
* any keyword arguments setting other style parameters |
|
|
|
""" |
|
|
|
""" |
|
|
|
operation = getattr(colors, op_name) |
|
|
|
|
|
|
|
|
|
|
|
if self._op is None: |
|
|
|
def parametric_style(color, step=10, max_=None, base_style=None, |
|
|
|
raise RuntimeError('ParametricStyle is not instanciable') |
|
|
|
**kwargs): |
|
|
|
|
|
|
|
""" |
|
|
|
defaults = {} |
|
|
|
Generate a parametric Style instance of the parametric operation |
|
|
|
if base_style is not None: |
|
|
|
This takes several parameters: |
|
|
|
if isinstance(base_style, type): |
|
|
|
* a `step` which correspond on how many colors will be needed |
|
|
|
base_style = base_style() |
|
|
|
* a `max_` which defines the maximum amplitude of the color effect |
|
|
|
defaults.update(base_style.to_dict()) |
|
|
|
* a `base_style` which will be taken as default for everything |
|
|
|
defaults.update(kwargs) |
|
|
|
except colors |
|
|
|
|
|
|
|
* any keyword arguments setting other style parameters |
|
|
|
super(ParametricStyleBase, self).__init__(**defaults) |
|
|
|
""" |
|
|
|
|
|
|
|
if max_ is None: |
|
|
|
if max_ is None: |
|
|
|
violency = { |
|
|
|
violency = { |
|
|
|
'darken': 50, |
|
|
|
'darken': 50, |
|
|
|
'lighten': 50, |
|
|
|
'lighten': 50, |
|
|
|
'saturate': 100, |
|
|
|
'saturate': 100, |
|
|
|
'desaturate': 100, |
|
|
|
'desaturate': 100, |
|
|
|
'rotate': 360 |
|
|
|
'rotate': 360 |
|
|
|
} |
|
|
|
} |
|
|
|
max__ = violency[op_name] |
|
|
|
max_ = violency[self._op] |
|
|
|
else: |
|
|
|
|
|
|
|
max__ = max_ |
|
|
|
def modifier(index): |
|
|
|
|
|
|
|
percent = max_ * index / (step - 1) |
|
|
|
def modifier(index): |
|
|
|
return getattr(colors, self._op)(color, percent) |
|
|
|
percent = max__ * index / (step - 1) |
|
|
|
|
|
|
|
return operation(color, percent) |
|
|
|
self.colors = list(map(modifier, range(0, max(2, step)))) |
|
|
|
|
|
|
|
|
|
|
|
colors = list(map(modifier, range(0, max(2, step)))) |
|
|
|
|
|
|
|
|
|
|
|
class LightenStyle(ParametricStyleBase): |
|
|
|
if base_style is None: |
|
|
|
|
|
|
|
return Style(colors=colors, **kwargs) |
|
|
|
"""Create a style by lightening the given color""" |
|
|
|
opts = dict(base_style.__dict__) |
|
|
|
|
|
|
|
opts.update({'colors': colors}) |
|
|
|
_op = 'lighten' |
|
|
|
opts.update(kwargs) |
|
|
|
|
|
|
|
return Style(**opts) |
|
|
|
|
|
|
|
|
|
|
|
class DarkenStyle(ParametricStyleBase): |
|
|
|
return parametric_style |
|
|
|
|
|
|
|
|
|
|
|
"""Create a style by darkening the given color""" |
|
|
|
style = get_style_for(op) |
|
|
|
|
|
|
|
parametric_styles[name] = style |
|
|
|
_op = 'darken' |
|
|
|
setattr(sys.modules[__name__], name, style) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SaturateStyle(ParametricStyleBase): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""Create a style by saturating the given color""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_op = 'saturate' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DesaturateStyle(ParametricStyleBase): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""Create a style by desaturating the given color""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_op = 'desaturate' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RotateStyle(ParametricStyleBase): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""Create a style by rotating the given color""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_op = 'rotate' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parametric_styles = { |
|
|
|
|
|
|
|
'lighten': LightenStyle, |
|
|
|
|
|
|
|
'darken': DarkenStyle, |
|
|
|
|
|
|
|
'saturate': SaturateStyle, |
|
|
|
|
|
|
|
'desaturate': DesaturateStyle, |
|
|
|
|
|
|
|
'rotate': RotateStyle |
|
|
|
|
|
|
|
} |
|
|
|