Issue #233 new

pygame.draw.ellipse does not draw ellipses with odd sizes

donLorenzo
created an issue

Reported by Florian Krause on the pygame mailing list:

I was actually wrong. It seems even worse. Pygama is not capable to draw ellipses with odd sizes at all. It will always be the same ellipse as x-1, y-1.
E.g. an elipse with size 3,3 will result in the same ellipse as the one with size 2,2.
Can anyone reproduce this?

Code to reproduce:

import pygame
pygame.init()
screen = pygame.display.set_mode((100, 100))
pygame.draw.ellipse(screen, (255,0,0), (0,0,5,5))
pygame.display.update()

The resulting ellipse will have a 4x4 size

Comments (6)

  1. donLorenzo reporter

    Well here is a larger ellipse with a vertical line as visual aid.

    import pygame
    pygame.init()
    screen = pygame.display.set_mode((200,200))
    pygame.draw.line(screen, (127,127,127), (61,0), (61,120))
    pygame.draw.ellipse(screen, (255,255,255), (0,0,61,61))
    pygame.draw.ellipse(screen, (255,255,255), (0,62,60,60))
    pygame.display.update()
    

    Notice that the two ellipses have the same distance from the vertical line but the upper one should be one pixel larger (touching the line).

    So, there is a bug unless you can show me otherwise and not just assert it. issue233.png

  2. donLorenzo reporter

    I drew two ellipses one with 20x20 and one with 21x21 size. I did this twice. once in the GIMP and once with pygame

    issue233.png

    By looking at the code I understand why pygame draws two ellipses of identical size. What I don't understand is why we consider this okay.

    I think if the API was draw.ellipse(center, x_radius, y_radius) you might have a point that we cannot have floating point radii but given the current API of draw.ellipse(x,y,w,h) I certainly would expect a result similar to the GIMP's output.

  3. Florian Krause

    Absolutely, yes.

    I would argue to either

    1) Make all valid diameter integer values produce the expected output

    or

    2) Make the ellipse work with radii only

    I strongly prefer 1) though.

  4. Log in to comment