From 4ed2a6d3aad98df0a1c7e80e14c455f493d56813 Mon Sep 17 00:00:00 2001 From: SallarShayegan Date: Wed, 2 Apr 2025 22:59:01 +0200 Subject: [PATCH] the display of athmos has been implemented --- athmos.py | 27 ++++++++++++++++++++++++--- main.py | 14 ++++++++++---- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/athmos.py b/athmos.py index 107b0af..b79f11d 100755 --- a/athmos.py +++ b/athmos.py @@ -1,12 +1,33 @@ from .fonts import * from .colors import * +import pygame +import math + +MAX_COUNT = 9 class Athmos: def __init__(self, screen): + self.index = 0 + self.filenames = [] self.screen = screen + self.show_list = True + self.surface = pygame.Surface((self.screen.get_width()/3, self.get_display_count()*40), pygame.SRCALPHA) + + def get_display_count(self): + return min(MAX_COUNT, len(self.filenames)) def update(self): - name = font_helvetica16.render("kir", False, color_primary_light) - self.screen.blit(name, ((self.screen.get_width() - name.get_width())/2, - 20)) \ No newline at end of file + if self.show_list: + for i in range(self.get_display_count()): + 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): + text_surface = font_helvetica16.render(text, False, "black", color_primary_light) + else: + text_surface = font_helvetica16.render(text, False, color_primary_light) + # name.set_alpha(opacity) + 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.get_height() - self.surface.get_height())/2)) \ No newline at end of file diff --git a/main.py b/main.py index 62335af..dea300f 100755 --- a/main.py +++ b/main.py @@ -47,7 +47,7 @@ class GuiMain: for i in range(len(self.fx_mode_labels)): self.knobs.append(Knobs(self)) - self.set_fx_mode(self.fx_mode) + #self.set_fx_mode(self.fx_mode) self.mute_button = BinaryButton( self.screen, @@ -66,7 +66,7 @@ class GuiMain: False ) - self.athmos = Athmos(self) + self.athmos = Athmos(self.screen) self.clock = pygame.time.Clock() self.running = True @@ -85,6 +85,12 @@ class GuiMain: for b in self.fx_mode_buttons: b.focused = (b.name == mode) + def set_athmo_index(self, index): + self.athmos.index = index + + def set_athmo_filenames(self, filenames): + self.athmos.filenames = filenames + def update(self): if self.running: # fill the screen with a color to wipe away anything from last frame @@ -93,6 +99,8 @@ class GuiMain: self.screen.blit(self.label_surface, (0,0)) self.label_surface = pygame.Surface((self.screenW, self.screenH), pygame.SRCALPHA) + self.athmos.update() + self.knobs[self.fx_mode].display() for button in self.fx_mode_buttons: @@ -110,8 +118,6 @@ class GuiMain: self.rloop_button.display() self.rec_button.display() - self.athmos.update() - pygame.draw.polygon(self.screen, "white", [(0, self.screenH/2), (self.screenW*3 / 19, self.screenH), (0, self.screenH)]) # flip() the display to put your work on screen pygame.display.flip()