the athmo list display has been bug-fixed and a opacity gradient has been added to the list
This commit is contained in:
17
athmos.py
17
athmos.py
@ -12,22 +12,31 @@ class Athmos:
|
|||||||
self.filenames = []
|
self.filenames = []
|
||||||
self.screen = screen
|
self.screen = screen
|
||||||
self.show_list = True
|
self.show_list = True
|
||||||
self.surface = pygame.Surface((self.screen.get_width()/3, self.get_display_count()*40), pygame.SRCALPHA)
|
self.surface = pygame.Surface((0,0), pygame.SRCALPHA)
|
||||||
|
|
||||||
|
def set_filenames(self,filenames):
|
||||||
|
self.filenames = filenames
|
||||||
|
self.surface = pygame.Surface(
|
||||||
|
(self.screen.get_width()*2/3, self.get_display_count()*40),
|
||||||
|
pygame.SRCALPHA)
|
||||||
|
|
||||||
def get_display_count(self):
|
def get_display_count(self):
|
||||||
return min(MAX_COUNT, len(self.filenames))
|
return min(MAX_COUNT, len(self.filenames))
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
self.surface.fill("black")
|
||||||
if self.show_list:
|
if self.show_list:
|
||||||
for i in range(self.get_display_count()):
|
for i in range(self.get_display_count()):
|
||||||
text = self.filenames[(i-self.index-math.floor(self.get_display_count()/2))%len(self.filenames)]
|
text = self.filenames[(i-self.index-math.floor(self.get_display_count()/2))%len(self.filenames)]
|
||||||
# opacity = math.floor(i * 2 * 255 / MAX_COUNT if i < MAX_COUNT/2 else 255 - i * 2 * 255 / MAX_COUNT)
|
|
||||||
if i == math.floor(self.get_display_count()/2):
|
if i == math.floor(self.get_display_count()/2):
|
||||||
text_surface = font_helvetica16.render(text, False, "black", color_primary_light)
|
text_surface = font_helvetica16.render(text, False, "black", color_primary_light)
|
||||||
else:
|
else:
|
||||||
text_surface = font_helvetica16.render(text, False, color_primary_light)
|
text_surface = font_helvetica16.render(text, False, color_primary_light)
|
||||||
# name.set_alpha(opacity)
|
opacity = math.floor((i+1) * 2 * 255 / MAX_COUNT
|
||||||
|
if i < MAX_COUNT/2
|
||||||
|
else (MAX_COUNT-i) * 2 * 255 / MAX_COUNT)
|
||||||
|
text_surface.set_alpha(opacity)
|
||||||
self.surface.blit(text_surface, ((0, self.surface.get_height()/self.get_display_count()*i)))
|
self.surface.blit(text_surface, ((0, self.surface.get_height()/self.get_display_count()*i)))
|
||||||
|
|
||||||
self.screen.blit(self.surface, ((self.screen.get_width() - self.surface.get_width())/2,
|
self.screen.blit(self.surface, (self.screen.get_width()/3,
|
||||||
(self.screen.get_height() - self.surface.get_height())/2))
|
(self.screen.get_height() - self.surface.get_height())/2))
|
||||||
2
main.py
2
main.py
@ -89,7 +89,7 @@ class GuiMain:
|
|||||||
self.athmos.index = index
|
self.athmos.index = index
|
||||||
|
|
||||||
def set_athmo_filenames(self, filenames):
|
def set_athmo_filenames(self, filenames):
|
||||||
self.athmos.filenames = filenames
|
self.athmos.set_filenames(filenames)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
if self.running:
|
if self.running:
|
||||||
|
|||||||
Reference in New Issue
Block a user