small refactoring

This commit is contained in:
SallarShayegan
2025-02-23 21:11:49 +01:00
parent 1e0d5de886
commit 106d93b9c3
2 changed files with 6 additions and 4 deletions

View File

@ -5,8 +5,8 @@ class Knob:
def __init__(self, screen, color, radius, position):
self.screen = screen
self.color = color
self.radius = radius
self.fill_color = color
self.position = position
self.value = 0
@ -14,11 +14,12 @@ class Knob:
self.value = value
def get_pointer_position(self):
x = self.radius * math.cos((self.value * 0.8 * 2 + 0.7) * math.pi) + self.position[0]
y = self.radius * math.sin((self.value * 0.8 * 2 + 0.7) * math.pi) + self.position[1]
angle = (self.value * 0.8 * 2 + 0.7) * math.pi
x = self.radius * math.cos(angle) + self.position[0]
y = self.radius * math.sin(angle) + self.position[1]
return(x, y)
def display(self):
pygame.draw.circle(self.screen, self.fill_color, self.position, self.radius)
pygame.draw.circle(self.screen, self.color, self.position, self.radius)
pygame.draw.line(self.screen, "black", self.position, self.get_pointer_position(), 3)