forked from Decentrala/website
add text to poster image and also write events to a text file
This commit is contained in:
parent
b6a198ed5f
commit
dfa84076b7
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,5 +7,6 @@ poster.html
|
|||||||
poster.pdf
|
poster.pdf
|
||||||
poster_light.png
|
poster_light.png
|
||||||
poster_dark.png
|
poster_dark.png
|
||||||
|
poster.txt
|
||||||
http.access.log
|
http.access.log
|
||||||
http.error.log
|
http.error.log
|
||||||
|
@ -56,12 +56,24 @@ def drawPoster(events, bg, fg, month:int):
|
|||||||
_, _, w, _ = draw.textbbox((0, 0), subheader, font=fontIosevka)
|
_, _, w, _ = draw.textbbox((0, 0), subheader, font=fontIosevka)
|
||||||
draw.text(((W-w)/2, 240), subheader, font=fontIosevka, fill=fg)
|
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)
|
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:
|
for event in events:
|
||||||
|
|
||||||
|
# Add event to image poster
|
||||||
date = DAYS_OF_WEEK_SR[event["date"].weekday()]
|
date = DAYS_OF_WEEK_SR[event["date"].weekday()]
|
||||||
day = event["date"].day
|
day = event["date"].day
|
||||||
title = event["title"]
|
title = event["title"]
|
||||||
@ -70,6 +82,11 @@ def drawPoster(events, bg, fg, month:int):
|
|||||||
draw.text((120, height), eventText, font=fontIosevkaSmall, fill=fg)
|
draw.text((120, height), eventText, font=fontIosevkaSmall, fill=fg)
|
||||||
height += 70
|
height += 70
|
||||||
|
|
||||||
|
# Add event to textfile
|
||||||
|
textfile.write(eventText + "\n")
|
||||||
|
|
||||||
|
textfile.close()
|
||||||
|
|
||||||
def drawCircle(x, y):
|
def drawCircle(x, y):
|
||||||
r = 10
|
r = 10
|
||||||
draw.ellipse((x - r, y - r, x + r, y+r), fill=fg, outline=(0, 0, 0), width=0)
|
draw.ellipse((x - r, y - r, x + r, y+r), fill=fg, outline=(0, 0, 0), width=0)
|
||||||
|
Loading…
Reference in New Issue
Block a user