I'm using Pygame to draw some things. The problem is that they have a lot of aliased edges:
I want to make them softer, like this:
My idea so far was to draw the shape in double size, and then use
pygame.transform.smoothscale(surf, (w/2, h/2))
to shrink it to the size I want.
Unfortunately if I'm drawing my shapes on a transparent surface, the smoothscale turns the edges that were touching transparent pixels black!
To make Pygame's text use anti-aliasing, just pass True for the second parameter of the render() method. The pygame. draw. aaline() and pygame.
gfxdraw allows anti-aliasing for all shapes, where draw only 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. Follow this answer to receive notifications.
In order to draw antialiased filled shapes with pygame, use the module gfxdraw
and draw one antialiased outline and one regular filled shape.
From https://www.pygame.org/docs/ref/gfxdraw.html:
To draw an anti aliased and filled shape, first use the aa* version of the
function, and then use the filled version.
Note that you need to import gfxdraw
explicitly, i.e. from pygame import gfxdraw
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With