1 import pygame
2
3 pygame.init()
4 screen = pygame.display.set_mode((640, 480))
5 # -----设置背景-----
6 background = pygame.Surface(screen.get_size())
7 background.fill((255, 240, 245)) # fill LavenderBlush
8 # ----- 绘制一个圆 -----
9 ballsurface = pygame.Surface((640, 480))
10 ballsurface.set_colorkey((0, 0, 0)) # 将黑色设为色键
11 pygame.draw.circle(ballsurface, (224, 255, 255), (640//2, 480//2), 480//2)
12 # ----- 布局 ------
13 background = background.convert()
14 screen.blit(background, (0, 0))
15
16 ballsurface = ballsurface.convert_alpha()
17 screen.blit(ballsurface, (0, 0))
18 # ----- 显示 -----
19 pygame.display.flip()
绘制一个圆2,运用colorkey alpha
猜你喜欢
转载自www.cnblogs.com/xiyu714/p/9031537.html
今日推荐
周排行