aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2019-03-09 08:33:19 +0300
committerBonfaceKilz2020-08-08 03:26:09 +0300
commite3c0745fdc3bf33cb10256643f3b1469ee6614c4 (patch)
tree0c62867d7c225d702c98acc52e002e6f17534f60 /wqflask/utility
parent97646f40bd8bff699f9ee2721fc9c960162ad3eb (diff)
downloadgenenetwork2-e3c0745fdc3bf33cb10256643f3b1469ee6614c4.tar.gz
Add draw_open_polygon() utility
* wqflask/utility/pillow_utils.py: New method.
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/pillow_utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/wqflask/utility/pillow_utils.py b/wqflask/utility/pillow_utils.py
index 4a666e4b..dfbf3e19 100644
--- a/wqflask/utility/pillow_utils.py
+++ b/wqflask/utility/pillow_utils.py
@@ -4,6 +4,8 @@ import utility.logger
logger = utility.logger.getLogger(__name__ )
BLACK = ImageColor.getrgb("black")
+WHITE = ImageColor.getrgb("white")
+
# def draw_rotated_text(canvas: Image, text: str, font: ImageFont, xy: tuple, fill: ImageColor=BLACK, angle: int=-90):
def draw_rotated_text(canvas, text, font, xy, fill=BLACK, angle=-90):
# type: (Image, str, ImageFont, tuple, ImageColor, int)
@@ -14,3 +16,10 @@ def draw_rotated_text(canvas, text, font, xy, fill=BLACK, angle=-90):
tmp_img2 = tmp_img.rotate(angle, expand=1)
tmp_img2.save("/tmp/{}.png".format(text), format="png")
canvas.paste(im=tmp_img2, box=tuple([int(i) for i in xy]))
+
+# def draw_open_polygon(canvas: Image, xy: tuple, fill: ImageColor=WHITE, outline: ImageColor=BLACK):
+def draw_open_polygon(canvas, xy, fill=None, outline=BLACK, width=0):
+ # type: (Image, tuple, ImageColor, ImageColor)
+ draw_ctx = ImageDraw.Draw(canvas)
+ draw_ctx.polygon(xy, fill=fill)
+ draw_ctx.line(xy, fill=outline, width=width)