From 56149858bfb290a107da7ade23726929d0328ac3 Mon Sep 17 00:00:00 2001 From: fram3d Date: Sat, 1 Jun 2024 17:02:14 +0200 Subject: [PATCH] add mesh --- image_poster.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/image_poster.py b/image_poster.py index 4bd04d39..9be0ea8d 100755 --- a/image_poster.py +++ b/image_poster.py @@ -7,6 +7,7 @@ from PIL import Image, ImageDraw, ImageFont import csv import datetime as dt from dateutil import relativedelta +from cairosvg import svg2png CURRENT_TIME = dt.date.today() NEXT_MONTH = CURRENT_TIME + relativedelta.relativedelta(months=1, day=1) @@ -93,7 +94,7 @@ def drawPoster(events, bg, fg, month:int): r = 50 draw.ellipse((x - r, y - r, x + r, y+r), fill=fg, outline=(0, 0, 0), width=0) - LCX = 3100 # logo center x + LCX = 415 # logo center x LCY = 4350 # logo center y d = 190 # delta drawCircle(LCX - d, LCY) @@ -106,6 +107,20 @@ def drawPoster(events, bg, fg, month:int): draw.line([(LCX, LCY), (LCX, LCY + d), (LCX + d, LCY), (LCX, LCY - d)], fill=fg, width=20, joint=None) draw.text((LCX - 1.7*d, LCY + 1.5*d), "dmz.rs", font=fontIosevka, fill=fg) + if bg == (255,255,255): + mesh_svg = svg2png(url='site/img/mesh-light.svg') + if bg == (0,0,0): + mesh_svg = svg2png(url='site/img/mesh-dark.svg') + mesh_svg_bytes = io.BytesIO(mesh_svg) + mesh_img = Image.open(mesh_svg_bytes) + + mesh_img = mesh_img.resize((W,H)) + mesh_img.thumbnail((W,H), Image.Resampling.LANCZOS) + + mesh_w, mesh_h = mesh_img.size + mesh_position = (W - mesh_w, H - mesh_h) + img.paste(mesh_img, mesh_position, mesh_img) + return img def main():