This commit is contained in:
Lukas Schulz 2020-12-20 01:41:59 +01:00
parent 73abd95afa
commit 8b1101ecf6

17
main.py
View file

@ -34,6 +34,9 @@ artist_name=""
is_playing = False
currently_scrolling_artist = False
currently_scrolling_title = False
token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)
font = ImageFont.load_default()
@ -97,19 +100,22 @@ def drawCanvas():
songinfo.text((songinfo_offset_x,songinfo_offset_y), artist_name)
#scrolling_text(song_name,songinfo_offset_x, songinfo_offset_y+10)
if(font.getsize(song_name)[0]>160):
x = threading.Thread(target=scrolling_text,args=(song_name,songinfo_offset_x,songinfo_offset_y+10))
global currently_scrolling_title
if(font.getsize(song_name)[0]>160 and !currently_scrolling_title):
x = threading.Thread(target=scrolling_text,args=(song_name,songinfo_offset_x,songinfo_offset_y+10),currently_scrolling_title)
x.start()
print('scrolling text started')
if(font.getsize(artist_name)[0]>160):
global currently_scrolling_artist
if(font.getsize(artist_name)[0]>160 and !currently_scrolling_artist):
y = threading.Thread(target=scrolling_text,args=(artist_name,songinfo_offset_x,songinfo_offset_y))
y = threading.Thread(target=scrolling_text,args=(artist_name,songinfo_offset_x,songinfo_offset_y),currently_scrolling_artist)
y.start()
showImage(canvas)
def scrolling_text(text,offset_x=0,offset_y=0):
def scrolling_text(text,offset_x=0,offset_y=0,scrolling_Boolean):
scrolling_Boolean = True
for i in range(font.getsize(text)[0]-160):
scrolled_text_canvas = Image.new('RGB', (160, 11), color = 'black')
scrolled_text = ImageDraw.Draw(scrolled_text_canvas)
@ -126,6 +132,7 @@ def scrolling_text(text,offset_x=0,offset_y=0):
showImage(scrolled_text_canvas, offset_x, offset_y)
time.sleep(0.1)
#print('scrolled '+str(i)+' px')
scrolling_Boolean = False