2019-02-28 20:20:05 +01:00
|
|
|
from DesignEntity import DesignEntity
|
|
|
|
from PIL import ImageDraw, ImageOps
|
|
|
|
|
2019-07-13 08:05:35 +02:00
|
|
|
|
2019-02-28 20:20:05 +01:00
|
|
|
class BoxDesign (DesignEntity):
|
|
|
|
"""Redefinition of ImageDraw.Draw.Rectangle"""
|
2019-07-13 08:05:35 +02:00
|
|
|
|
2019-02-28 20:20:05 +01: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)
|
2019-02-28 20:20:05 +01:00
|
|
|
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)
|
2019-02-28 20:20:05 +01:00
|
|
|
bottomright = self.size
|
2019-03-10 07:52:53 +01:00
|
|
|
self.corners = [topleft, bottomright]
|
2019-02-28 20:20:05 +01:00
|
|
|
|
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)
|