我正在尝试创建一个像这里这样的应用程序:
基本上很多用pygame绘制的重叠圆圈。我无法弄清楚如何混合圆圈以使它们半透明。那就是让重叠的颜色显示出来。到目前为止,我的代码是这样的:
import sys, random, time
import pygame
from pygame.locals import *
from pygame import draw
rand = random.randint
pygame.init( )
W = 320
H = 320
size = (W, H)
screen = pygame.display.set_mode(size)
run = True
while 1:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE :
run = not run
else:
sys.exit()
if run:
xc = rand(1, W)
yc = rand(1, H)
rc = rand(1, 25)
red = rand(1, 255)
grn = rand(1, 255)
blu = rand(1, 255)
draw.circle(screen, (red, grn, blu, 200), (xc, yc), rc, 0)
pygame.display.flip()