Wheel :)
This commit is contained in:
commit
25e143d406
3 changed files with 159 additions and 0 deletions
29
allitems
Normal file
29
allitems
Normal file
|
@ -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
|
28
items.db
Normal file
28
items.db
Normal file
|
@ -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
|
102
wheel.py
Normal file
102
wheel.py
Normal file
|
@ -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()
|
||||
|
Loading…
Reference in a new issue