Search code examples
pythonpygamedraw

Python, pygame, how to draw an arc


I'm trying to draw an arc in pygame, the actual size and position of the arc aren't important, at the moment all I get is an elipse.

My code:

import pygame
import sys

pygame.init()
size = width, height = 400, 600
screen = pygame.display.set_mode(size)

while 1:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()


    screen.fill((0,0,0))

    pygame.draw.arc(screen, (255, 255, 255), (50, 50, 50, 50), 10, 20, 1)

    pygame.display.flip()

Why does this draw a full circle instead of an arc?


Solution

  • From the pygame docs:

    The two angle arguments are the initial and final angle in radians, with the zero on the right.

    You are starting at 10 radians, and sweeping to 20. I assume you meant to do this in degrees. 10 radians is around 572 degrees.