Description
Issue №2924 opened by flodri at 2021-12-17 17:50:02
Environment:
- Operating system (e.g. Windows, Linux(Debian), Linux(Ubuntu), Mac): Windows 10
- Python version (e.g. 3.7.9, 3.8.5) : 3.7.8
- SDL version (e.g. SDL 2.0.12): 2.0.16
- PyGame version (e.g. 2.0.0.dev10, 1.9.6): 2.1.0
Current behavior:
gfxdraw.circle, .aacircle, .filled_circle, .arc and .pie all add a central pixel that shouldn't be here, making the circles 1 pixel too big to the right and bottom.
So for exemple a 16 px radius circle will actually be draw as a 16.5 px radius circle and fit in a 33x33 box instead of 32x32.
Expected behavior:
What draw.circle does, circles of the correct dimension.
Steps to reproduce:
- use gfxdraw.circle, .aacircle, .filled_circle, .arc or .pie to draw a circle
- see that they're 1 pixel too big to the right and bottom
Test code
import pygame
import pygame.gfxdraw
pygame.init()
screen = pygame.display.set_mode((128, 128))
pygame.draw.rect(screen, (255, 0, 0), (32, 32, 64, 64)) # bouding box if the circle was the correct size
pygame.gfxdraw.circle(screen, 64, 64, 32, (0, 255, 0))
running = True
while running:
events = pygame.event.get()
for event in events:
if (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE) or (event.type == pygame.QUIT):
running = False
pygame.display.flip()
Comments
# # ankith26 commented at 2021-12-31 04:29:21
Thanks for the bug report! This is something we should fix while porting gfxdraw
functions to pygame.draw
. gfxdraw
is a vendored library, that is not well maintained these days
# # Starbuck5 commented at 2022-05-02 08:22:15
I believe it's that the underlying circle algorithm only draws odd numbered widths and heights. So it's only one pixel off half the time No, you're right, it's 1 pixel off all the time.
I propose we add a small note to the docs documenting this behavior, then close this issue (sortof as a wontfix), because I don't believe pygame wants to mess with SDL_gfx functions just for this.