Files
SantoscopeUI/main.py

70 lines
2.3 KiB
Python

import pygame
from knob import *
# pygame setup
pygame.init()
screenW = 561
screenH = 325
screen = pygame.display.set_mode((screenW, screenH))
color_primary = (0, 190, 180)
color_primary_light = (0, 255, 245)
# Create and position the knobs
knobs_radius = screenW / 25
knobs_spacing = knobs_radius * 2
knobs_x = (screenW - (knobs_radius + knobs_spacing) * 2) / 2
x = knobs_x
knobs_y = (screenH - (knobs_radius + knobs_spacing) * 3) / 2
y = knobs_y
knobs = []
for i in range(8):
knobs.append(Knob(screen, color_primary, knobs_radius, (x, y)))
y += knobs_radius + knobs_spacing
if i == 3 or i == 6:
x += knobs_radius + knobs_spacing
y = knobs_y
pygame.font.init() # you have to call this at the start,
# if you want to use this module.
font_helvetica = pygame.font.SysFont('Helvetica', 30)
clock = pygame.time.Clock()
running = True
while running:
# poll for events
# pygame.QUIT event means the user clicked X to close your window
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# fill the screen with a color to wipe away anything from last frame
screen.fill("black")
# RENDER YOUR GAME HERE
fx_label = font_helvetica.render('REVERB WET', False, color_primary_light)
fx_value = font_helvetica.render('[ 86% ]', False, color_primary_light)
label_x = screenW - fx_label.get_width() - 20
label_y = (screenH - fx_label.get_height() - fx_value.get_height()) / 2
screen.blit(fx_label, (label_x, label_y))
screen.blit(fx_value, (label_x, screenH / 2))
pygame.draw.line(screen, color_primary_light, (label_x - 10, label_y), (label_x - 10, screenH - label_y), 2)
pygame.draw.line(screen, color_primary_light, (knobs_x + knobs_radius * 1.5, screenH/2), (label_x - 10, screenH/2), 2)
pygame.draw.line(screen, color_primary_light, knobs[2].get_position(), (knobs_x + knobs_radius * 1.5, screenH/2), 2)
knobs[2].set_value(0.86)
knobs[2].set_color(color_primary_light)
for i in range(8):
knobs[i].display()
pygame.draw.polygon(screen, "white", [(0, screenH/2), (screenW*3/19, screenH), (0, screenH)])
# flip() the display to put your work on screen
pygame.display.flip()
clock.tick(60) # limits FPS to 60
pygame.quit()