这是我的代码
import pygame
BLUE = (0 , 0 , 255, 1)
screen=pygame.display.set_mode((500,500))
clock = pygame.time.Clock()
surface = pygame.Surface((500,500), pygame.SRCALPHA)
def draw_circle_alpha(surface, color, center, radius):
target_rect = pygame.Rect(center, (0, 0)).inflate((radius * 2, radius * 2))
shape_surf = pygame.Surface(target_rect.size, pygame.SRCALPHA)
pygame.draw.circle(shape_surf, color, (radius, radius), radius)
surface.blit(shape_surf, target_rect)
isPressed = False
while True:
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN:
isPressed = True
elif event.type == pygame.MOUSEBUTTONUP:
isPressed = False
elif event.type == pygame.MOUSEMOTION and isPressed == True:
x, y = pygame.mouse.get_pos() # returns the position of mouse cursor
draw_circle_alpha(surface, BLUE, (x, y), 15)
pygame.display.flip()
screen.blit(surface, (0,0))
它有点工作并产生这种很酷的效果: see here
但我希望我的线路保持透明。我该怎么做?