From 25e143d406e334627d616ef751a36800c1189aaa Mon Sep 17 00:00:00 2001 From: Quantum Date: Sun, 3 Dec 2023 01:17:25 -0500 Subject: [PATCH] Wheel :) --- allitems | 29 ++++++++++++++++ items.db | 28 +++++++++++++++ wheel.py | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 159 insertions(+) create mode 100644 allitems create mode 100644 items.db create mode 100644 wheel.py diff --git a/allitems b/allitems new file mode 100644 index 0000000..6519c3f --- /dev/null +++ b/allitems @@ -0,0 +1,29 @@ +Go +Rust +C +BASIC +Carbon +Shell Script +Perl +R +Dart +Python +C++ +Lua +GDScript +C# +Scratch +CH32 +ATMega328 +RP2040 +TI Graphing Calcluator +Linux Kernel +UEFI +Commodore 64 +Nintendo (tm) +ESP32 +Windows +Linux +BSD +SerenityOS +GMod diff --git a/items.db b/items.db new file mode 100644 index 0000000..4f191a7 --- /dev/null +++ b/items.db @@ -0,0 +1,28 @@ +Go +Rust +C +BASIC +Carbon +Perl +R +Dart +Python +C++ +Lua +GDScript +C# +Scratch +CH32 +ATMega328 +RP2040 +TI Graphing Calcluator +Linux Kernel +UEFI +Commodore 64 +Nintendo (tm) +ESP32 +Windows +Linux +BSD +SerenityOS +GMod diff --git a/wheel.py b/wheel.py new file mode 100644 index 0000000..5109851 --- /dev/null +++ b/wheel.py @@ -0,0 +1,102 @@ +import pygame +import time +import math +import random +import colorsys + +# Initialize Pygame +pygame.init() + +WIDTH = 1920 +HEIGHT = 1080 + +# Set up the drawing window +screen = pygame.display.set_mode([WIDTH, HEIGHT]) + +def polar2cart(center, angle, radius): + angle = math.radians(angle) + return (center[0] + radius * math.cos(angle), center[1] + radius * math.sin(angle)) + +# Define a function to draw a circle divided into n segments +def draw_divided_circle(surface, items, offset): + segments = len(items) + center = (WIDTH / 2, HEIGHT / 2) + radius = min(WIDTH, HEIGHT) * .9 / 2 + color = (255, 255, 255) + + font = pygame.font.SysFont(None, 36) + + pygame.draw.circle(surface, color, center, radius, 1) + angle_step = 360 / segments + + for i, item in enumerate(items): + text_surface = font.render(item, True, (255, 255, 255)) + + angle = i * angle_step + offset + + rotated_surface = pygame.transform.rotate(text_surface, 180 + angle + angle_step / 2) + + text_pos = polar2cart(center, angle + angle_step / 2, radius * .6) + text_rect = rotated_surface.get_rect() + text_rect.center = text_pos + screen.blit(rotated_surface, text_rect) + + end_pos = polar2cart(center, angle, radius) + pygame.draw.line(surface, color, center, end_pos) + + +with open('items.db', 'r') as f: + items = f.read().strip('\n') + items = items.split('\n') +random.shuffle(items) + + +running = True +t0 = time.time() +ang = 0 +while running: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + + screen.fill((24, 24, 24)) + + draw_divided_circle(screen, items, ang + 180) + # pygame.draw.line(screen, (255, 255, 255), (WIDTH / 2, HEIGHT - (HEIGHT * .96)), (WIDTH / 2, HEIGHT - (HEIGHT * .99))) + pygame.draw.line(screen, (255, 255, 255), (WIDTH - (WIDTH * .78), HEIGHT / 2), (WIDTH - (WIDTH * .85), HEIGHT / 2)) + + t = time.time() - t0 + bs_scale = (random.random() + 1) + if t < 6.2831 * bs_scale: + d_ang = (math.cos(t + 3.1415 * bs_scale) + 1) / (t + 1) + ang += d_ang * (random.random() / 2 + 1) + else: + i = int(-(ang % 360) / (360 / len(items))) + print(items[i]) + + bigfont = pygame.font.SysFont(None, 112) + + spinny = -25 + d_spin = 0.1 + + while 1: + spinny -= d_spin + d_spin *= 1.0005 + + r, g, b = colorsys.hsv_to_rgb(spinny / 100 % 255, 1, 1) + + text_surface = bigfont.render(items[i], True, (r * 255, g * 255, b * 255)) + + rotated_surface = pygame.transform.rotate(text_surface, spinny) + + text_rect = rotated_surface.get_rect() + text_rect.center = (WIDTH / 2, HEIGHT / 2) + + screen.fill((24, 24, 24)) + screen.blit(rotated_surface, text_rect) + pygame.display.flip() + + pygame.display.flip() + +pygame.quit() +