我想在曲面内画一个半圆。所以我想用
pygame.draw.arc()
但我不知道如何在表面内绘制圆弧,我已经看到了official_docs并且正在使用math.radians()
将度数转换为弧度,但我看不到圆弧。正在画一个圆圈...
import pygame
import math
pygame.init()
width, height = 800, 600
screen = pygame.display.set_mode((width, height))
surf = pygame.Surface((100, 100))
surf.fill("green")
rect = surf.get_rect(center=(100, 100))
run = 1
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = 0
screen.fill((255, 202, 135))
pygame.draw.circle(surf, (255, 255, 255), (30,30),25)
pygame.draw.arc(surf, (255, 255, 255), rect, math.radians(270), math.radians(90))
screen.blit(surf, rect)
pygame.display.flip()
pygame.quit()
提前致谢
必须相对于绘制圆弧的表面设置圆弧的位置,而不是相对于屏幕上表面的位置:
pygame.draw.arc(surf, (255, 255, 255), rect, math.radians(270), math.radians(90))
pygame.draw.arc(surf, (255, 255, 255), (0, 0, 100, 100), math.radians(270), math.radians(90))