import pygame
import math
import random

pygame.init()
WIDTH, HEIGHT = 800, 800
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("静态复杂组合图形")
clock = pygame.time.Clock()
cx, cy = WIDTH // 2, HEIGHT // 2

# 生成渐变色彩
def get_color(angle, offset=0):
    r = int(127 + 127 * math.sin(angle + offset))
    g = int(127 + 127 * math.sin(angle + offset + 2))
    b = int(127 + 127 * math.sin(angle + offset + 4))
    return (r, g, b)

# 深色背景
screen.fill((10, 10, 30))

# 1. 多层点阵圆环
ring_num = 8
for idx in range(ring_num):
    r = 380 - idx * 45
    point_cnt = 72 + idx * 12
    for i in range(point_cnt):
        theta = 2 * math.pi * i / point_cnt
        x = cx + r * math.cos(theta)
        y = cy + r * math.sin(theta)
        color = get_color(theta, idx)
        size = 3 + idx % 4
        pygame.draw.circle(screen, color, (int(x), int(y)), size)

# 2. 多层螺旋线
spiral_layer = 4
for s in range(spiral_layer):
    base_angle = s * math.pi / 2
    for t in range(0, 1200, 6):
        r = t / 3.2
        theta = t * 0.025 + base_angle
        x = cx + r * math.cos(theta)
        y = cy + r * math.sin(theta)
        color = get_color(theta + s)
        pygame.draw.circle(screen, color, (int(x), int(y)), 2)

# 3. 嵌套正多边形
poly_sides = [3, 4, 6, 8]
poly_r = 220
for sides in poly_sides:
    points = []
    for i in range(sides):
        theta = 2 * math.pi * i / sides
        x = cx + poly_r * math.cos(theta)
        y = cy + poly_r * math.sin(theta)
        points.append((int(x), int(y)))
    color = get_color(0, sides)
    pygame.draw.polygon(screen, color, points, 2)
    poly_r -= 50

# 4. 中心放射线条
ray_num = 36
for i in range(ray_num):
    theta = 2 * math.pi * i / ray_num
    ex = cx + 160 * math.cos(theta)
    ey = cy + 160 * math.sin(theta)
    color = get_color(theta)
    pygame.draw.line(screen, color, (cx, cy), (int(ex), int(ey)), 1)

# 中心实心圆
pygame.draw.circle(screen, (255, 255, 255), (cx, cy), 25)

# 随机装饰小点
for _ in range(60):
    rx = random.randint(0, WIDTH)
    ry = random.randint(0, HEIGHT)
    c = get_color(rx * 0.01)
    pygame.draw.circle(screen, c, (rx, ry), 1)

# 刷新画面
pygame.display.flip()

# 保持窗口，点击关闭
running = True
while running:
    clock.tick(60)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

pygame.quit()