我正在尝试在 pygame 中绘制简单的半透明矩形。我试过这段代码:
import pygame, sys,pygame.mixer
pygame.init()
size = (width, height) = (400, 400)
screen = pygame.display.set_mode(size)
screen.fill((255,255,255))
pygame.draw.rect(screen, (23, 100, 255, 50), (100,100,100,100),0)
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
running = False
但正如你所见,矩形不是半透明的。就像我插入颜色 23, 100, 255, 255) 而不是 (23, 100, 255, 50)。