add A3 poster format
This commit is contained in:
parent
d4a8d92615
commit
e8b4495c58
@ -40,30 +40,30 @@ def load_events(csv_path:str, month:int) -> list[dict]:
|
|||||||
return events
|
return events
|
||||||
|
|
||||||
def drawPoster(events, bg, fg, month:int):
|
def drawPoster(events, bg, fg, month:int):
|
||||||
fontFacade = ImageFont.truetype('./site/font/Facade-Sud.woff', size=110)
|
fontFacade = ImageFont.truetype('./site/font/Facade-Sud.woff', size=365)
|
||||||
fontIosevka = ImageFont.truetype('./site/font/iosevka-regular.woff', size=60)
|
fontIosevka = ImageFont.truetype('./site/font/iosevka-regular.woff', size=200)
|
||||||
fontIosevkaSmall = ImageFont.truetype('./site/font/iosevka-regular.woff', size=45)
|
fontIosevkaSmall = ImageFont.truetype('./site/font/iosevka-regular.woff', size=150)
|
||||||
|
|
||||||
W = 1200
|
W = 3508
|
||||||
H = 1500
|
H = 4960
|
||||||
img = Image.new('RGB', (W, H), bg)
|
img = Image.new('RGB', (W, H), bg)
|
||||||
draw = ImageDraw.Draw(img)
|
draw = ImageDraw.Draw(img)
|
||||||
|
|
||||||
header = "DECENTRALA"
|
header = "DECENTRALA"
|
||||||
_, _, w, _ = draw.textbbox((0, 0), header, font=fontFacade)
|
_, _, w, _ = draw.textbbox((0, 0), header, font=fontFacade)
|
||||||
draw.text(((W-w)/2, 50), header, font=fontFacade, fill=fg)
|
draw.text(((W-w)/2, 165), header, font=fontFacade, fill=fg)
|
||||||
|
|
||||||
subheader = f"Plan za {MONTHS_SR[month.month - 1]}"
|
subheader = f"Plan za {MONTHS_SR[month.month - 1]}"
|
||||||
_, _, w, _ = draw.textbbox((0, 0), subheader, font=fontIosevka)
|
_, _, w, _ = draw.textbbox((0, 0), subheader, font=fontIosevka)
|
||||||
draw.text(((W-w)/2, 170), subheader, font=fontIosevka, fill=fg)
|
draw.text(((W-w)/2, 560), subheader, font=fontIosevka, fill=fg)
|
||||||
|
|
||||||
height = 300
|
height = 990
|
||||||
|
|
||||||
draw.text((50, height), "Radionice pocinju u 19h u DC Krovu", font=fontIosevkaSmall, fill=fg)
|
draw.text((165, height), "Radionice pocinju u 19h u DC Krovu", font=fontIosevkaSmall, fill=fg)
|
||||||
height += 60
|
height += 200
|
||||||
|
|
||||||
draw.text((50, height), "Svi dogadjaji su uvek besplatni", font=fontIosevkaSmall, fill=fg)
|
draw.text((165, height), "Svi dogadjaji su uvek besplatni", font=fontIosevkaSmall, fill=fg)
|
||||||
height += 90
|
height += 300
|
||||||
|
|
||||||
# Write list of events to sperate text file as well
|
# Write list of events to sperate text file as well
|
||||||
textfile=open("poster.txt","w")
|
textfile=open("poster.txt","w")
|
||||||
@ -81,8 +81,8 @@ def drawPoster(events, bg, fg, month:int):
|
|||||||
title = event["title"]
|
title = event["title"]
|
||||||
pad = " " if event["date"].day < 10 else ""
|
pad = " " if event["date"].day < 10 else ""
|
||||||
eventText = f"{date} {day}. {pad} {title}"
|
eventText = f"{date} {day}. {pad} {title}"
|
||||||
draw.text((50, height), eventText, font=fontIosevkaSmall, fill=fg)
|
draw.text((165, height), eventText, font=fontIosevkaSmall, fill=fg)
|
||||||
height += 70
|
height += 200
|
||||||
|
|
||||||
# Add event to textfile
|
# Add event to textfile
|
||||||
textfile.write(eventText + "\n")
|
textfile.write(eventText + "\n")
|
||||||
@ -90,20 +90,20 @@ def drawPoster(events, bg, fg, month:int):
|
|||||||
textfile.close()
|
textfile.close()
|
||||||
|
|
||||||
def drawCircle(x, y):
|
def drawCircle(x, y):
|
||||||
r = 10
|
r = 50
|
||||||
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)
|
||||||
|
|
||||||
LCX = 1050 # logo center x
|
LCX = 3100 # logo center x
|
||||||
LCY = 1300 # logo center y
|
LCY = 4350 # logo center y
|
||||||
d = 50 # delta
|
d = 190 # delta
|
||||||
drawCircle(LCX - d, LCY)
|
drawCircle(LCX - d, LCY)
|
||||||
drawCircle(LCX, LCY)
|
drawCircle(LCX, LCY)
|
||||||
drawCircle(LCX, LCY - d)
|
drawCircle(LCX, LCY - d)
|
||||||
drawCircle(LCX, LCY + d)
|
drawCircle(LCX, LCY + d)
|
||||||
drawCircle(LCX + d, LCY)
|
drawCircle(LCX + d, LCY)
|
||||||
|
|
||||||
draw.line([(LCX - d, LCY), (LCX + d, LCY)], fill=fg, width=5, joint=None)
|
draw.line([(LCX - d, LCY), (LCX + d, LCY)], fill=fg, width=20, joint=None)
|
||||||
draw.line([(LCX, LCY), (LCX, LCY + d), (LCX + d, LCY), (LCX, LCY - d)], fill=fg, width=5, joint=None)
|
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)
|
draw.text((LCX - 1.7*d, LCY + 1.5*d), "dmz.rs", font=fontIosevka, fill=fg)
|
||||||
|
|
||||||
return img
|
return img
|
||||||
|
Loading…
Reference in New Issue
Block a user