diff --git a/knob.py b/knob.py index b61754f..10b7f03 100644 --- a/knob.py +++ b/knob.py @@ -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) \ No newline at end of file diff --git a/main.py b/main.py index 4d43376..ca864aa 100644 --- a/main.py +++ b/main.py @@ -7,6 +7,7 @@ screenW = 561 screenH = 325 screen = pygame.display.set_mode((screenW, screenH)) +# Create and position the knobs knobs_radius = screenW / 25 knobs_spacing = knobs_radius * 2 knobs_x = (screenW - (knobs_radius + knobs_spacing) * 2) / 2