import pygame import time import math import random import colorsys import sys # 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) d_ang = (math.e**(-0.7*t)) * (math.cos(0.25*t*bs_scale) + 1) ang += d_ang * (random.random() / 2 + 1) else: i = int( (((ang - 45) % 360) + (360/len(items)) / 2) // (360/len(items)) ) print(ang) print(items[i]) bigfont = pygame.font.SysFont(None, 112) spinny = -25 d_spin = 0.1 while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False sys.exit(0) 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)) scaled_surface = pygame.transform.scale_by(text_surface, d_spin/2) rotated_surface = pygame.transform.rotate(scaled_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()