yes.
This commit is contained in:
parent
9f07752e78
commit
c5611f889f
1 changed files with 12 additions and 15 deletions
27
main.py
27
main.py
|
@ -34,9 +34,6 @@ 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()
|
||||
|
@ -100,39 +97,39 @@ def drawCanvas():
|
|||
songinfo.text((songinfo_offset_x,songinfo_offset_y), artist_name)
|
||||
|
||||
#scrolling_text(song_name,songinfo_offset_x, songinfo_offset_y+10)
|
||||
global currently_scrolling_title
|
||||
if(font.getsize(song_name)[0]>160 and not currently_scrolling_title):
|
||||
x = threading.Thread(target=scrolling_text,args=(song_name,currently_scrolling_title,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))
|
||||
x.start()
|
||||
print('scrolling text started')
|
||||
global currently_scrolling_artist
|
||||
if(font.getsize(artist_name)[0]>160 and not currently_scrolling_artist):
|
||||
if(font.getsize(artist_name)[0]>160):
|
||||
|
||||
y = threading.Thread(target=scrolling_text,args=(artist_name,currently_scrolling_artist,songinfo_offset_x,songinfo_offset_y))
|
||||
y = threading.Thread(target=scrolling_text,args=(artist_name,songinfo_offset_x,songinfo_offset_y))
|
||||
y.start()
|
||||
|
||||
showImage(canvas)
|
||||
|
||||
|
||||
def scrolling_text(text,scrolling_Boolean,offset_x=0,offset_y=0):
|
||||
scrolling_Boolean = True
|
||||
def scrolling_text(text,offset_x=0,offset_y=0):
|
||||
scroll_frame_time = (font.getsize(text)[0]-160)/(10/2)
|
||||
if(scroll_frame_time<0.1):
|
||||
scroll_frame_time = 0.1
|
||||
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)
|
||||
scrolled_text.text((-i,0), text)
|
||||
showImage(scrolled_text_canvas, offset_x, offset_y)
|
||||
time.sleep(0.1)
|
||||
time.sleep(scroll_frame_time)
|
||||
#print('scrolled '+str(i)+' px')
|
||||
if((5-(font.getsize(text)[0]-160)*0.2)>0):
|
||||
time.sleep(5-(font.getsize(text)[0]-160)*0.2)
|
||||
time.sleep(5-(font.getsize(text)[0]-160)*2*scroll_frame_time)
|
||||
|
||||
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)
|
||||
scrolled_text.text(((-(font.getsize(text)[0]-160))+i+1,0), text)
|
||||
showImage(scrolled_text_canvas, offset_x, offset_y)
|
||||
time.sleep(0.1)
|
||||
time.sleep(scroll_frame_time)
|
||||
#print('scrolled '+str(i)+' px')
|
||||
scrolling_Boolean = False
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue