added an animation for vanishing the label path

This commit is contained in:
SallarShayegan
2025-03-01 19:30:48 +01:00
parent 899c065eb0
commit f0237bbb7e
2 changed files with 68 additions and 25 deletions

View File

@ -12,6 +12,9 @@ class Knob:
self.position = position
self.value = value
self.focused = False
self.fade_count_down = 300
self.vanish_label_path = False
self.label_path = []
def set_value(self, value):
self.value = value
@ -26,6 +29,8 @@ class Knob:
else:
self.focused = False
self.color = color_primary
self.fade_count_down = 300
if not self.vanish_label_path: self.label_path = []
def get_position(self):
return self.position
@ -46,7 +51,11 @@ class Knob:
pos = pygame.mouse.get_pos()
if math.sqrt(math.pow(pos[0]-self.position[0],2) + math.pow(pos[1]-self.position[1],2)) < self.radius:
self.group.set_focused(self)
if self.focused: self.fade_count_down -= 1
if self.fade_count_down == 0:
self.vanish_label_path = True
self.set_focused(False)
pygame.draw.circle(screen, self.color, self.position, self.radius)
pygame.draw.line(screen, "black", self.position, self.get_pointer_position(), 4)