You've already forked AiraPulsar
Improvement
This commit is contained in:
59
pulsar/1.py
Normal file
59
pulsar/1.py
Normal file
@@ -0,0 +1,59 @@
|
||||
import pygame
|
||||
import sys
|
||||
|
||||
# 初始化 Pygame
|
||||
pygame.init()
|
||||
|
||||
# 设置窗口大小
|
||||
width, height = 800, 600
|
||||
screen = pygame.display.set_mode((width, height))
|
||||
pygame.display.set_caption("Pygame Draw Example")
|
||||
|
||||
# 定义颜色
|
||||
BLACK = (0, 0, 0)
|
||||
WHITE = (255, 255, 255)
|
||||
RED = (255, 0, 0)
|
||||
GREEN = (0, 255, 0)
|
||||
BLUE = (0, 0, 255)
|
||||
YELLOW = (255, 255, 0)
|
||||
|
||||
# 主循环
|
||||
running = True
|
||||
while running:
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
running = False
|
||||
|
||||
# 填充背景
|
||||
screen.fill(WHITE)
|
||||
|
||||
# 绘制线条
|
||||
pygame.draw.line(screen, RED, (50, 50), (200, 50), 5)
|
||||
pygame.draw.aaline(screen, BLUE, (50, 100), (200, 100))
|
||||
|
||||
# 绘制矩形
|
||||
pygame.draw.rect(screen, GREEN, (50, 150, 150, 100), 0) # 填充矩形
|
||||
pygame.draw.rect(screen, BLACK, (250, 150, 150, 100), 5) # 边框矩形
|
||||
|
||||
# 绘制圆形
|
||||
pygame.draw.circle(screen, YELLOW, (400, 200), 50, 0) # 填充圆形
|
||||
pygame.draw.circle(screen, BLACK, (500, 200), 50, 5) # 边框圆形
|
||||
|
||||
# 绘制椭圆
|
||||
pygame.draw.ellipse(screen, BLUE, (50, 300, 200, 100), 0) # 填充椭圆
|
||||
pygame.draw.ellipse(screen, BLACK, (300, 300, 200, 100), 5) # 边框椭圆
|
||||
|
||||
# 绘制多边形
|
||||
points = [(600, 400), (700, 300), (800, 400), (700, 500)]
|
||||
pygame.draw.polygon(screen, GREEN, points, 0) # 填充多边形
|
||||
pygame.draw.polygon(screen, BLACK, points, 5) # 边框多边形
|
||||
|
||||
# 绘制弧
|
||||
pygame.draw.arc(screen, RED, (50, 450, 200, 100), 0, 3.14, 5) # 弧
|
||||
|
||||
# 更新显示
|
||||
pygame.display.flip()
|
||||
|
||||
# 退出 Pygame
|
||||
pygame.quit()
|
||||
sys.exit()
|
||||
Reference in New Issue
Block a user