[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] PATCH: pygame.draw moire hole fix



Hi Jeffrey,

An anti-aliased filled ellipse function has been suggested before. But finding a suitable drawing algorithm was always a problem. Here is the most recent thread:

http://article.gmane.org/gmane.comp.python.pygame/23447

The source for pygame.draw is here:

https://bitbucket.org/pygame/pygame/src/37fb5da907e24c581e5bffbbaf9e4073162e496d/src/draw.c?at=default

There is also pygame.gfxdraw, which has an anti-aliased width 1 draw circle:

https://bitbucket.org/pygame/pygame/src/37fb5da907e24c581e5bffbbaf9e4073162e496d/src/SDL_gfx/SDL_gfxPrimitives.c?at=default

But this is all Pygame for SDL 1. SDL 2 is a game changer; maybe shape rendering will be done in opengl.

Lenard Lindstrom

On 14-02-02 08:58 PM, Jeffrey Kleykamp wrote:
Hi everyone,

I'm new here so please be nice.

I created new versions of pygame.draw.circle, arc, ellipse that don't suffer from the moire hole problem. I don't know if there's been some discussion or if a patch has already been submitted regarding this, but my version fixes them. See the picture that's attached. I also included functions to draw regular polygons and wedges.

The strategy my circle draw function uses is to draw regular polygons with high number of sides so you can't tell it that it's actually a polygon. Similarly for other draw functions.

I wanted to use aalines but it doesn't fill the polygon. If you look at the picture the first column is the current draw function, the second is the new draw function, the third is a composite of the new draw and aalines, the last is only the aalines.

Running the file runs the test code that made the attached picture. Sorry I didn't comment much. I'll go back an fix it if there's interest in this code.

I also couldn't find the pygame.draw source code to look at, so it would be nice if someone pointed me to where that was. Thanks!

Sincerely,
Jeffrey

--

      Jeffrey Kleykamp