当前位置:   article > 正文

pygame中draw绘制图形_pygame绘制draw

pygame绘制draw
import pygame
import sys
from pygame.locals import *
import math
pygame.init()

WHITE = (255,255,255)
BLACK = (0,0,0)
size = width,height = 640,480
screen = pygame.display.set_mode(size)
clock = pygame.time.Clock()

moving = False
while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            sys.exit()
  
    screen.fill(WHITE)
    #矩形
    pygame.draw.rect(screen,BLACK,(50,50,100,50),1) #0填充
    #多边形
    pygame.draw.polygon(screen,BLACK,[(200,200),(100,300),(300,300)],1)
    #圆形
    pygame.draw.circle(screen,BLACK,(400,400),75,1)
    #椭圆形
    pygame.draw.ellipse(screen,BLACK,(100,100,400,100),1)
    #弧线
    pygame.draw.arc(screen,BLACK,(200,50,300,100),math.pi,math.pi*2,1)
    #线段
    pygame.draw.line(screen,BLACK,(20,20),(20,100),1)
    pygame.draw.aaline(screen,BLACK,(30,30),(400,800),0) #抗锯齿 0


    pygame.display.flip()
    clock.tick(10) #1s10次
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36

运行结果:
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/154529
推荐阅读
相关标签
  

闽ICP备14008679号