I’m working on some code involving use of the pygame library to draw a circle to a surface. The code to draw the circle looks something like the following:
surf = pygame.Surface((2000,2000))
pygame.draw.circle(surf,
pygame.Color("white"),
(1000,1000),
508,
50)
The problem is that the resulting circle has artifacts

Is there anyway to draw a circle like this without getting these artifacts?
What you see is most likely a problem with pygame.draw.circle implementation. Most likely pygame developer foolishly assumed that you can draw thick circle by drawing several circles in sequence, increasing radius by one for every circle. That’s not going to work in practice and you’ll get moire pattern like the one you see. Try increasing circle line thickness by 100 or 200 and see what happens. If it gets worse, then it is
pygame.draw.circle‘s fault.A solution would be to provide your own circle rendering routine. This can be certainly be done, but for optimum performance it makes sense to do it in C/C++ extension module for pygame OR using OpenGL (with or without fragment shaders).
To get a perfect circle for every scanline you’ll have to calculate start and end of filled area for every scanline. It might be possible to do this in python with tolerable performance by using pygame.draw.line to draw individual scanlines.