43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
import os
|
|
|
|
from PIL import Image, ImageDraw
|
|
|
|
class Config:
|
|
|
|
def __init__(self):
|
|
if os.path.exists('/usr/share/fonts/source-pro/'):
|
|
self.fnt_R_path = "/usr/share/fonts/source-pro/SourceSansPro-Regular.otf"
|
|
self.fnt_RI_path = "/usr/share/fonts/source-pro/SourceSansPro-It.otf"
|
|
self.fnt_RB_path = "/usr/share/fonts/source-pro/SourceSansPro-Bold.otf"
|
|
elif os.path.exists('/usr/share/fonts/libertine'):
|
|
self.fnt_R_path = "/usr/share/fonts/libertine/LinBiolinum_Rah.ttf"
|
|
self.fnt_RI_path = "/usr/share/fonts/libertine/LinBiolinum_RIah.ttf"
|
|
self.fnt_RB_path = "/usr/share/fonts/libertine/LinBiolinum_RBah.ttf"
|
|
else:
|
|
self.fnt_R_path = "/usr/share/fonts/TTF/LinBiolinum_Rah.ttf"
|
|
self.fnt_RI_path = "/usr/share/fonts/TTF/LinBiolinum_RIah.ttf"
|
|
self.fnt_RB_path = "/usr/share/fonts/TTF/LinBiolinum_RBah.ttf"
|
|
|
|
from pygal.style import Style
|
|
self.pygal_custom_style = Style(
|
|
background='white',
|
|
foreground='black',
|
|
font_family='Source Code Pro',
|
|
gauge_background="red",
|
|
colors=('#000', '#777'))
|
|
|
|
self.charts_opts = {'style': self.pygal_custom_style, 'show_legend': False, 'margin_right': 7, 'margin_left': 2, 'margin_bottom': 1, 'margin_top': 1}
|
|
|
|
class RuleModule:
|
|
|
|
def __init__(self):
|
|
self.coeff = 0.92
|
|
|
|
def draw_module(self, config, width, height):
|
|
image = Image.new('RGB', (width, height), 'white')
|
|
draw = ImageDraw.Draw(image)
|
|
|
|
draw.rectangle((int((1-self.coeff) * width), 0, int(self.coeff * width), height), fill="black")
|
|
|
|
return image
|