applies_alpha()
trick
josmiley / Luke spywoker
(mutualaccount)
not a project, just a trick
how to applies alpha channel from a surface to another ?
surface1 and surface2 must have the same size
from pygame import *
def applies_alpha(surface1,surface2):
#return a surface
#applies the alpha channel from surface1 to surface2
output = surface2.copy().convert_alpha()
surfarray.pixels_alpha(output)[:] = surfarray.array_alpha(surface1)[:]
return output
def applies_alpha_ip(surface1,surface2):
#applies the alpha channel in place from surface1 to surface2
surfarray.pixels_alpha(surface2)[:] = surfarray.array_alpha(surface1)
Changes
Links
- Home Page
- http://www.pygame.org/