transit times aligned and bolded, other small interface adjustments
This commit is contained in:
parent
b837fcac02
commit
f9d88c3eef
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,11 +1,7 @@
|
||||
/__pycache__/
|
||||
|
||||
# Effie's python environment
|
||||
/bin/
|
||||
/include/
|
||||
/lib/
|
||||
/lib64/
|
||||
/pyvenv.cfg
|
||||
/.venv/
|
||||
|
||||
/test*.png
|
||||
/cache.sqlite
|
||||
|
||||
58
__main__.py
58
__main__.py
@ -16,55 +16,67 @@ BLACK = 0x000000 # 00 BGR
|
||||
WHITE = 0xffffff # 01
|
||||
YELLOW = 0x00ffff # 10
|
||||
RED = 0x0000ff # 11
|
||||
fontmm = ImageFont.truetype('assets/NETWORKSANS-2019-REGULAR.TTF', 20)
|
||||
font24 = ImageFont.truetype('assets/NETWORKSANS-2019-REGULAR.TTF', 24)
|
||||
font42 = ImageFont.truetype('assets/NETWORKSANS-2019-REGULAR.TTF', 42)
|
||||
font64 = ImageFont.truetype('assets/NETWORKSANS-2019-REGULAR.TTF', 64)
|
||||
fontstd = ImageFont.truetype('assets/NETWORKSANS-2019-REGULAR.TTF', 64)
|
||||
fontmins = ImageFont.truetype('assets/NETWORKSANS-2019-BOLD.TTF', 96)
|
||||
fonttime = ImageFont.truetype('assets/NETWORKSANS-2019-REGULAR.TTF', 92)
|
||||
fontmm = ImageFont.truetype('assets/NETWORKSANS-2019-REGULAR.TTF', 20)
|
||||
fonthigh = ImageFont.truetype('assets/NETWORKSANS-2019-REGULAR.TTF', 42)
|
||||
|
||||
image = Image.new('RGB', (800, 480), WHITE)
|
||||
draw = ImageDraw.Draw(image)
|
||||
|
||||
# Backing image
|
||||
with Image.open('assets/ui test 2.png').convert('RGBA') as bg:
|
||||
with Image.open('assets/ui test 3.png').convert('RGBA') as bg:
|
||||
image.paste(bg, (0, 0))
|
||||
|
||||
# Time
|
||||
draw.text((-3, 480-3), f'{now:%H:%M}', font=fonttime, anchor="ls", fill=WHITE)
|
||||
timehour = f'{now:%H}'
|
||||
timemin = f'{now:%M}'
|
||||
timehourlength = draw.textlength(timehour, font=fonttime)-3
|
||||
timeminstart = timehourlength + draw.textlength(':', font=fonttime)-3
|
||||
draw.text((-3, 480-3), timehour, font=fonttime, anchor="ls", fill=WHITE)
|
||||
draw.text((timehourlength, 480-12), f':', font=fonttime, anchor="ls", fill=WHITE)
|
||||
draw.text((timeminstart, 480-3), timemin, font=fonttime, anchor="ls", fill=WHITE)
|
||||
|
||||
# Date
|
||||
dateday = f'{now:%d}'
|
||||
draw.text((-3, 320), dateday, font=font64, anchor="ls", fill=WHITE)
|
||||
datedaylength = draw.textlength(dateday, font=font64)
|
||||
draw.text((datedaylength + 5, 320), f'{now:%b}', font=font64, anchor="lt", fill=WHITE)
|
||||
datedaylength = draw.textlength(dateday, font=fontstd)
|
||||
draw.text((-3, 320), dateday, font=fontstd, anchor="ls", fill=WHITE)
|
||||
draw.text((datedaylength + 5, 320), f'{now:%b}', font=fontstd, anchor="lt", fill=WHITE)
|
||||
|
||||
# Temperature
|
||||
temp = 6
|
||||
temphigh = 12
|
||||
draw.text((-3, 200), f'{temp}°', font=font64, anchor="ls", fill=WHITE)
|
||||
draw.text((123, 237), f'{temphigh}', font=font42, anchor="ms", fill=WHITE)
|
||||
temphigh = 6
|
||||
draw.text((-3, 200), f'{temp}°', font=fontstd, anchor="ls", fill=WHITE)
|
||||
draw.text((124, 238), f'{temphigh}', font=fonthigh, anchor="ms", fill=WHITE)
|
||||
|
||||
# Rainfall
|
||||
rainfall = 3
|
||||
rainfall = 6
|
||||
rainthreshold = 5
|
||||
if rainfall > rainthreshold:
|
||||
rainimgpath = 'assets/rain.png'
|
||||
else:
|
||||
rainimgpath = 'assets/sun.png'
|
||||
draw.text((40, 0), f'{rainfall}', font=font64, anchor="mt")
|
||||
draw.text((40, 0), f'{rainfall}', font=fontstd, anchor="mt")
|
||||
with Image.open(rainimgpath) as rainimg:
|
||||
image.paste(rainimg, mask=rainimg)
|
||||
draw.text((40, 55), f'mm', font=fontmm, anchor="mt")
|
||||
|
||||
# PTV
|
||||
draw.text((375, 120), f'{ptv_data["612 S"]}', font=font64, anchor="ms", fill=BLACK)
|
||||
draw.text((500, 120), f'{ptv_data["612 N"]}', font=font64, anchor="ms", fill=BLACK)
|
||||
draw.text((700, 120), f'{ptv_data["766 N"]}', font=font64, anchor="ms", fill=BLACK)
|
||||
draw.text((375, 270), f'{ptv_data["Union W Express"]}', font=font64, anchor="ms", fill=BLACK)
|
||||
draw.text((500, 270), f'{ptv_data["Union W"]}', font=font64, anchor="ms", fill=BLACK)
|
||||
draw.text((700, 270), f'{ptv_data["Union E"]}', font=font64, anchor="ms", fill=BLACK)
|
||||
draw.text((500, 420), f'{ptv_data["109 W"]}', font=font64, anchor="ms", fill=BLACK)
|
||||
draw.text((700, 420), f'{ptv_data["70 W"]}', font=font64, anchor="ms", fill=BLACK)
|
||||
# ETAs
|
||||
leftminsx = 375
|
||||
centerminsx = 545
|
||||
rightminsx = 715
|
||||
busminsy = 75
|
||||
trainminsy = 235
|
||||
tramminsy = 395
|
||||
draw.text((leftminsx, busminsy), f'{ptv_data["612 S"]}', font=fontmins, anchor="mt", fill=BLACK)
|
||||
draw.text((centerminsx, busminsy), f'{ptv_data["612 N"]}', font=fontmins, anchor="mt", fill=BLACK)
|
||||
draw.text((rightminsx, busminsy), f'{ptv_data["766 N"]}', font=fontmins, anchor="mt", fill=BLACK)
|
||||
draw.text((leftminsx, trainminsy), f'{ptv_data["Union W Express"]}', font=fontmins, anchor="mt", fill=BLACK)
|
||||
draw.text((centerminsx, trainminsy), f'{ptv_data["Union W"]}', font=fontmins, anchor="mt", fill=BLACK)
|
||||
draw.text((rightminsx, trainminsy), f'{ptv_data["Union E"]}', font=fontmins, anchor="mt", fill=BLACK)
|
||||
draw.text((centerminsx, tramminsy), f'{ptv_data["109 W"]}', font=fontmins, anchor="mt", fill=BLACK)
|
||||
draw.text((rightminsx, tramminsy), f'{ptv_data["70 W"]}', font=fontmins, anchor="mt", fill=BLACK)
|
||||
|
||||
image.save('test_before_palette.png')
|
||||
|
||||
|
||||
BIN
assets/NETWORKSANS-2019-BOLD.TTF
Normal file
BIN
assets/NETWORKSANS-2019-BOLD.TTF
Normal file
Binary file not shown.
BIN
assets/ui test 3.png
Normal file
BIN
assets/ui test 3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 36 KiB |
Loading…
Reference in New Issue
Block a user