Set color key in scene module
Anybody here who has used the pygame module before should know about a colorkey. How do I set it?
PS. In case anybody didn't know, a colorkey is a RGB(A) value that when bound to a picture, replaces all pixels that are the color of the colorkey with another color, or transparent.
Some thoughts running through my mind:
- Maybe go pixel by pixel in a for loop. Use an if statement to determine if the pixel is that color. No clue how to do that.
- Find a colorkey function. No clue how to do that.
- Be open to suggestions. I know how to do that.
Why use color-keying when PNG files have a real alpha channel? It's a lot less work to convert your textures to PNG and add a proper alpha channel, if you ask me. In any case,
PIL.Image.Image.putalphamay be what you're looking for. The docs aren't very clear about what exactly the
bandargument means though.
I have images in my clipboard I am using, plus the colorkey should be pretty easy. In pygame:
pygame.image.set_colorkey(0, 0, 0)
This takes any black on the image and converts it to clear.