Loading design...

A beautiful concentric rings created with Python Turtle. Read the code below, copy it, and try it in your own Python environment.
import pygame
import math
import sys
pygame.init()
WIDTH, HEIGHT = 800, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("3D Neon Circles")
clock = pygame.time.Clock()
BLACK = (0, 0, 0)
NUM_CIRCLES = 21
center_x = WIDTH // 2
center_y = HEIGHT // 2
vmin = min(WIDTH, HEIGHT) / 100
tilt = math.cos(math.radians(70))
amplitude = 22 * vmin
time = 0
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
running = False
dt = clock.get_time() / 1000.0
time += dt
screen.fill(BLACK)
for i in range(NUM_CIRCLES - 1, -1, -1):
size = i * 2.5 * vmin
if size < 1:
continue
delay = i * 0.08
cycle = 3.0
t = ((time + delay) % cycle) / cycle
y_offset = math.sin(t * 2 * math.pi) * amplitude
hue = abs(math.sin(t * 2 * math.pi)) * 360
w = int(size)
h = int(size * tilt)
if h < 2:
h = 2
x = center_x
y = center_y + y_offset
for layer in range(5, 0, -1):
glow_w = w + layer * 4
glow_h = h + layer * 4
shadow_color = pygame.Color(0, 0, 0)
shadow_color.hsva = ((
hue + 180) % 360, 20, 50, 100)
rect = pygame.Rect(0, 0, glow_w, glow_h)
rect.center = (int(x), int(y))
pygame.draw.ellipse(screen, (
shadow_color.r, shadow_color.g,
shadow_color.b), rect, 1)
for layer in range(1, 3):
inset_w = w - layer * 5
inset_h = h - layer * 5
if inset_w > 2 and inset_h > 2:
inset_color = pygame.Color(0, 0, 0)
inset_color.hsva = ((
hue + 90) % 360, 40, 60, 100)
rect = pygame.Rect(
0, 0, inset_w, inset_h)
rect.center = (int(x), int(y))
pygame.draw.ellipse(screen, (
inset_color.r, inset_color.g,
inset_color.b), rect, 1)
main_color = pygame.Color(0, 0, 0)
main_color.hsva = (hue % 360, 100, 100, 100)
rect = pygame.Rect(0, 0, w, h)
rect.center = (int(x), int(y))
pygame.draw.ellipse(screen, (
main_color.r, main_color.g,
main_color.b), rect, 3)
pygame.display.flip()
clock.tick(60)
pygame.quit()
sys.exit()