This commit is contained in:
Lukas Schulz 2020-12-20 13:30:53 +01:00
parent c5417606d6
commit 64657fd1d9

19
main.py
View file

@ -97,11 +97,14 @@ def showImage(image, offset_x = 0, offset_y = 0):
def drawCanvas():
canvas = Image.new('RGB', (192, 128), color = 'black')
was_playing = is_playing
cover_art = get_track()
if (cover_art is None):
return
if(was_playing and not is_playing):
scrollDownSongInfo()
if(is_playing):
canvas.paste(cover_art,(0,96))
canvas.paste(cover_art,(cover_art_offset_x,cover_art_offset_y))
songinfo = ImageDraw.Draw(canvas)
songinfo_offset_x = 33
songinfo_offset_y = 101
@ -120,6 +123,20 @@ def drawCanvas():
showImage(canvas)
def scrollDownSongInfo(offset_x=0,offset_y=96):
cover_art = get_track()
if (cover_art is None):
return
for i in range(32):
canvas = Image.new('RGB', (192,32), color = 'black')
canvas = canvas.paste(cover_art,(0,i))
songinfo = Image.Draw.Draw(canvas)
songinfo_offset_x = 33
songinfo.text((songinfo_offset_x,songinfo_offset_y+11+i), song_name)
songinfo.text((songinfo_offset_x,songinfo_offset_y+i), artist_name)
showImage(canvas, offset_x, offset_y)
def scrolling_text(text,offset_x=0,offset_y=0):
scroll_frame_time = (8/2)/(font.getsize(text)[0]-160)