E-Paper-Calendar/Calendar/BoxDesign.py

24 lines
744 B
Python
Raw Permalink Normal View History

from DesignEntity import DesignEntity
from PIL import ImageDraw, ImageOps
2019-07-13 08:05:35 +02:00
class BoxDesign (DesignEntity):
"""Redefinition of ImageDraw.Draw.Rectangle"""
2019-07-13 08:05:35 +02:00
def __init__(self, size, fill=None, outline=None, width=0):
2019-02-28 22:19:33 +01:00
super(BoxDesign, self).__init__((size[0]+1, size[1]+1), mask=True)
self.size = size
self.__define_corners__()
self.fill = fill
self.outline = outline
self.width = width
def __define_corners__(self):
2019-07-13 08:05:35 +02:00
topleft = (0, 0)
bottomright = self.size
2019-03-10 07:52:53 +01:00
self.corners = [topleft, bottomright]
2019-07-13 08:05:35 +02:00
def __finish_image__(self):
ImageDraw.Draw(self.__image__).rectangle(
self.corners, fill=self.fill, outline=self.outline, width=self.width)