import pygame
if __name__ == '__main__':
pygame.init()
screen = pygame.display.set_mode((600,400))
screen.fill((255,255,255))
"""
1.画直线
def line(Surface, color, start_pos, end_pos, width=1):
surface -- 画在哪个地方
color -- 线的颜色
star_pos -- 起点
end_pos -- 终点
width -- 线的宽度
"""
pygame.draw.line(screen ,(255,0,0),(0,0),(200,200),5)
pygame.draw.line(screen, (0, 255, 0), (0, 60), (200, 200), 5)
"""
def lines(Surface, color, closed, pointlist, width=1):
lines(画线的位置,颜色,closed,点的列表,width=1)
"""
pygame.draw.lines(screen,(0,0,255),False,[(20,20),(80,200),(200,100)])
1.画矩形
pygame.draw.rect(screen,(255,255,0),(200,200,200,200))
2.画曲线
def arc(Surface, color, Rect, start_angle, stop_angle, width=1):
Rect -- (x,y,(width,height)) 矩形
"""
from math import pi
pygame.draw.arc(screen,(0,0,0),(200,200,100,100),pi/2,pi)
"""
3.画圆
def circle(Surface, color, pos, radius, width=0):
"""
# import random
# pygame.draw.circle(screen,(random.randint(0,255),random.randint(0,255),random.randint(0,255), (400,200)),100)
"""
- 画椭圆
def ellipse(Surface, color, Rect, width=0):
"""
pygame.draw.ellipse(screen,(0,100,0),(100,200,300,80),1)
将内容展示在屏幕上
pygame.display.flip()
while True:
for event in pygame.event.get():
if event == pygame.QUIT:
exit()
网友评论