如何在曲面上绘制圆弧

问题描述 投票:0回答:1

我想在曲面内画一个半圆。所以我想用

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()

提前致谢

python pygame pygame-surface
1个回答
0
投票

必须相对于绘制圆弧的表面设置圆弧的位置,而不是相对于屏幕上表面的位置:

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))
© www.soinside.com 2019 - 2024. All rights reserved.