2
0
Fork 0

add text to poster image and also write events to a text file

This commit is contained in:
fram3d 2023-12-29 20:40:22 +01:00
parent b6a198ed5f
commit dfa84076b7
Signed by: fram3d
GPG Key ID: 938920E709EEA32A
2 changed files with 20 additions and 2 deletions

1
.gitignore vendored
View File

@ -7,5 +7,6 @@ poster.html
poster.pdf
poster_light.png
poster_dark.png
poster.txt
http.access.log
http.error.log

View File

@ -56,12 +56,24 @@ def drawPoster(events, bg, fg, month:int):
_, _, w, _ = draw.textbbox((0, 0), subheader, font=fontIosevka)
draw.text(((W-w)/2, 240), subheader, font=fontIosevka, fill=fg)
height = 410
height = 370
draw.text((120, height), "Radionice pocinju u 19h u DC Krovu", font=fontIosevkaSmall, fill=fg)
height += 100
height += 60
draw.text((120, height), "Svi dogadjaji su uvek besplatni", font=fontIosevkaSmall, fill=fg)
height += 90
# Write list of events to sperate text file as well
textfile=open("poster.txt","w")
textfile.write("Radionice pocinju u 19h u DC Krovu\n")
textfile.write("Svi dogadjaji su uvek besplatni\n")
# Loop to write events both to poster image and text file
for event in events:
# Add event to image poster
date = DAYS_OF_WEEK_SR[event["date"].weekday()]
day = event["date"].day
title = event["title"]
@ -70,6 +82,11 @@ def drawPoster(events, bg, fg, month:int):
draw.text((120, height), eventText, font=fontIosevkaSmall, fill=fg)
height += 70
# Add event to textfile
textfile.write(eventText + "\n")
textfile.close()
def drawCircle(x, y):
r = 10
draw.ellipse((x - r, y - r, x + r, y+r), fill=fg, outline=(0, 0, 0), width=0)