6

My question is simple: What is the difference between using pygame.draw and pygame.gfxdraw? I've looked on the pygame documentation, but no one has told what the difference between them is.

3 Answers 3

9

The draw function is a bit more stable, and also a bit faster that gfxdraw, although gfxdraw has more options, not only along the lines of antialiasing, but also drawing shapes. pygame.draw has only nine functions, whereas pygame.gfxdraw has 22 options, which include all 9 of the options supplied by draw. I recommend using gfxdraw even though its is "experimental" because it has more capabilities.

3

gfxdraw allows anti-aliasing for all shapes, where drawonly adds antialiasing to lines. I use gfxdraw by default. It has been marked 'experimental' for a long time now, but I've not had any issues.

1

Disclaimer: I Don't use pygame!

According to the gfxdraw doc page, it "Wraps SDL_gfx primatives", and so offers it as an API for those already familiar with it. It also appears to offers a little bit more than the more primitive normal draw. There also appears to be a few semantic differences here and there, so you'll need to compare each to its closest counterpart, and not assume anything.

As a final note, gfxdraw is experimental, and you should always take that into consideration before using it.

I hope this helps! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.