i want to draw a semicircle inside a surface. So i thought to use
pygame.draw.arc()
but i cant figure out how to draw the arc inside of a surface i have seen the official_docs and am using math.radians()
to convert degrees to radians but i cant see the arc. A circle is being drawn tho...
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()
thanks in advance
The position of the circle segment must of course be relative to the Surface
on which the circle segment is drawn and not the absolute position on which the Surface
is then placed on the screen:
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))