Pygame - Recolor Pixes Of A Certain Color To Another Using SurfArray (Array Slicing Issue)
I'm trying to make a palette swap functionality for a game, and I'm trying to find a way to change the color of pixels of a certain color to another. I've been able to make all of
Solution 1:
Maybe you're looking for something less general, but there is a replace method in the PixelArray
module used for replacing one color with another.
arr = PixelArray(surface)
arr.replace(fromColor, toColor)
del arr
That would change one color on a surface to another. The del
statement is there because otherwise the surface remains locked for as long as the PixelArray
object exists.
As for the array slicing, a section in the NumPy documentation explains the syntax.
Post a Comment for "Pygame - Recolor Pixes Of A Certain Color To Another Using SurfArray (Array Slicing Issue)"