Compare commits

..

No commits in common. "c02b3a87a04e3814e8334b7a55c709ba1d810ab6" and "d001b6bc80f1f22fa2fa49c0325ab9227c41483e" have entirely different histories.

7 changed files with 52 additions and 43 deletions

7
.gitignore vendored
View File

@ -1,10 +1,3 @@
/__pycache__/ /__pycache__/
# Effie's python environment
/bin
/include
/lib
/lib64
pyvenv.cfg
/test*.png /test*.png
/cache.sqlite /cache.sqlite

Binary file not shown.

View File

@ -9,47 +9,64 @@ BLACK = 0x000000 # 00 BGR
WHITE = 0xffffff # 01 WHITE = 0xffffff # 01
YELLOW = 0x00ffff # 10 YELLOW = 0x00ffff # 10
RED = 0x0000ff # 11 RED = 0x0000ff # 11
fontmm = ImageFont.truetype('NETWORKSANS-2019-REGULAR.TTF', 20) font18 = ImageFont.truetype('Font.ttc', 18)
font24 = ImageFont.truetype('NETWORKSANS-2019-REGULAR.TTF', 24) font24 = ImageFont.truetype('Font.ttc', 24)
font42 = ImageFont.truetype('NETWORKSANS-2019-REGULAR.TTF', 42) font40 = ImageFont.truetype('Font.ttc', 40)
font64 = ImageFont.truetype('NETWORKSANS-2019-REGULAR.TTF', 64) font64 = ImageFont.truetype('Font.ttc', 64)
fonttime = ImageFont.truetype('NETWORKSANS-2019-REGULAR.TTF', 92) font100 = ImageFont.truetype('Font.ttc', 100)
image = Image.new('RGB', (800, 480), WHITE) image = Image.new('RGB', (800, 480), WHITE)
draw = ImageDraw.Draw(image) draw = ImageDraw.Draw(image)
# Date/time
# Backing image
with Image.open('ui test 2.png').convert('RGBA') as bg:
image.paste(bg, (0, 0))
# Time
now = datetime.now() now = datetime.now()
draw.text((-3, 480-3), f'{now:%H:%M}', font=fonttime, anchor="ls", fill=WHITE) draw.text((10, 480-10-64), f'{now:%y/%m/%d}', font=font64, fill=BLACK)
draw.text((10, 480-10-64-10-100), f'{now:%I:%M}', font=font100, fill=BLACK)
# Date # TODO: weather
dateday = f'{now:%d}' draw.text((10, 10), '?mm', font=font64, fill=BLACK)
draw.text((-3, 320), dateday, font=font64, anchor="ls", fill=WHITE) draw.text((10, 10+64), '20°', font=font100, fill=BLACK)
datedaylength = draw.textlength(dateday, font=font64) draw.text((10, 10+64+100), '6° - 24°', font=font64, fill=BLACK)
draw.text((datedaylength + 5, 320), f'{now:%b}', font=font64, anchor="lt", fill=WHITE)
# Temperature # Bus
temp = 6 y = 0
temphigh = 12 with Image.open('icon_bus.png') as icon:
draw.text((-3, 200), f'{temp}°', font=font64, anchor="ls", fill=WHITE) image.paste(scale_to_height(icon), (230, y+50))
draw.text((123, 237), f'{temphigh}', font=font42, anchor="ms", fill=WHITE) draw.polygon((200, 0, 475, 0, 475, 50, 212.5, 50), fill=BLACK)
draw.text((215, y+5+16), 'Camberwell', font=font24, fill=WHITE)
draw.text((400, y+5), '612 S', font=font40, fill=WHITE, anchor='ma')
draw.text((400, y+55), '15', font=font64, fill=BLACK, anchor='ma')
draw.text((550, y+5), '612 N', font=font40, fill=BLACK, anchor='ma')
draw.text((550, y+55), '5', font=font64, fill=BLACK, anchor='ma')
draw.text((700, y+5), '766 N', font=font40, fill=BLACK, anchor='ma')
draw.text((700, y+55), '20', font=font64, fill=BLACK, anchor='ma')
# Rainfall # Train
rainfall = 3 y = 160
rainthreshold = 5 with Image.open('icon_train.png') as icon:
if rainfall > rainthreshold: image.paste(scale_to_height(icon), (280, y+50))
rainimgpath = 'rain.png' draw.polygon((240, 160, 595, 160, 595, 210, 252.5, 210), fill=BLACK)
else: draw.text((255, y+5+16), 'City', font=font24, fill=WHITE)
rainimgpath = 'sun.png' draw.text((400, y+5), 'Express', font=font40, fill=WHITE, anchor='ma')
draw.text((40, 0), f'{rainfall}', font=font64, anchor="mt") draw.text((400, y+55), '15', font=font64, fill=BLACK, anchor='ma')
with Image.open(rainimgpath) as rainimg: draw.text((550, y+5), 'All', font=font40, fill=WHITE, anchor='ma')
image.paste(rainimg,mask=rainimg) draw.text((550, y+55), '5', font=font64, fill=BLACK, anchor='ma')
draw.text((40, 55), f'mm', font=fontmm, anchor="mt") draw.text((700, y+5), 'Outbound', font=font40, fill=BLACK, anchor='ma')
draw.text((700, y+55), '20', font=font64, fill=BLACK, anchor='ma')
# Tram (y=320 to 470)
y = 320
with Image.open('icon_tram.png') as icon:
image.paste(scale_to_height(icon), (310, y+50))
draw.polygon((280, 320, 800, 320, 800, 370, 292.5, 370), fill=BLACK)
draw.text((295, y+5+16), 'City', font=font24, fill=WHITE)
draw.text((550, y+5), '109', font=font40, fill=WHITE, anchor='ma')
draw.text((550, y+55), '7', font=font64, fill=BLACK, anchor='ma')
draw.text((700, y+5), '70', font=font40, fill=WHITE, anchor='ma')
draw.text((700, y+55), '14', font=font64, fill=BLACK, anchor='ma')
# Line between left and right
draw.line((200, 0, 400, 800), fill=BLACK)
image.save('test_before_palette.png') image.save('test_before_palette.png')
@ -57,8 +74,8 @@ image.save('test_before_palette.png')
pal_image = Image.new('P', (1, 1)) pal_image = Image.new('P', (1, 1))
pal_image.putpalette((0x00,0x00,0x00, 0xff,0xff,0xff, 0xff,0xff,0x00, 0xff,0x00,0x00) + (0x00,0x00,0x00)*252) pal_image.putpalette((0x00,0x00,0x00, 0xff,0xff,0xff, 0xff,0xff,0x00, 0xff,0x00,0x00) + (0x00,0x00,0x00)*252)
# Convert the source image to the 4 colors, dithering if needed # Convert the source image to the 4 colors, dithering if needed
image_4color = image.quantize(palette=pal_image, dither=Image.NONE) image_4color = image.quantize(palette=pal_image)
image_4color.save('test_after_palette.png') image_4color.save('test.png')
show_on_screen = False show_on_screen = False
if show_on_screen: if show_on_screen:

BIN
rain.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -1 +0,0 @@
pillow==11.2.1

BIN
sun.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB