-
-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add draw.aaellipse #3016
base: main
Are you sure you want to change the base?
Add draw.aaellipse #3016
Conversation
… into draw.aaellipse()
draw_aacircle_xiaolinwu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this looks good to me. The new algorithm performs better than the one in gfxdraw (which has gaps in it) and adds the filling functionality. Tested a variety of parameters locally and all looked nice and behaved how I would expect.
Can't find any problems with the code, not going to pretend I understand the intricacies of the algorithm for drawing, but it looks sensible from a look over and produces an output I respect. 👍
# Conflicts: # docs/reST/ref/code_examples/draw_module_example.png
Note: before merging, correct versionadded in |
I moved |
aacircle is returning different return rect from aaellipse when it is off-surface
I see holes around the edges of the ellipse in this test case. import pygame
screen = pygame.display.set_mode((600,600))
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN and event.key == pygame.K_w:
pygame.image.save(screen, "output.png")
screen.fill("purple")
pygame.draw.aaellipse(screen, "red", [100,200,300,400])
pygame.display.flip()
pygame.quit() |
Other things I see.
|
This PR adds
draw.aaellipse
function, with width and thickness options.It is completely interchangeable with
draw.ellipse
in terms of arguments.Algorithm used is adapted from Xiaolin Wu's general fast antialiasing algorithm, and is very similar to
draw.aacircle
.Only notable difference: in aacircle, 8 pixels are drawn at once, but here, only 4, because ellipse has 2 symmetries. Because of that aaelipse has additional vertical drawing (aacircle has only horizontal but because of extra symmetries it is vertical at the same time).
It is added to docs too.
Sample code