[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] how to optimize these two function?
For your copy_blit, this is already built into SDL and pygame. It takes
a bit of magic mask settings for it to apply. But I'm pretty sure if
both source and destination Surfaces have per-pixel alphas, you can do a
copy blit by turning off the alpha flag on the source.
oldalpha = source.get_alpha()
source.set_alpha(None)
dest.blit(source, (0,0))
source.set_alpha(oldalpha)
It's been awhile since I've looked into Numeric. You'll need the docs on
hand, but this should be close to what actually works.
def change_alpha(surf, alpha):
...
alphas = pygame.surfarray.pixels_alpha(surf)
alphas[:] = Numeric.where(alphas, alpha, 0)
...