I'm creating a game with PyGame. There I want to create negative effect, where all screen becomes negative.
This is quite easy for simple shapes like rects: (and use rect
instead of pygame.draw.rect
)
# set negative to 1 to activate effect
negative = 0
def rect(win, color, area, width=0):
if negative:
pygame.draw.rect(win, (255 - color[0], 255 - color[1], 255 - color[2]), area, width)
else:
pygame.draw.rect(win, color, area, width)
But I don't know how to do this effect on images. I tried to do negative image copy, but if this effect will not be instant and will fill screen gradually, then this will not help.
# negative image copy
def negcopy(image):
neg = pygame.Surface(image.get_size())
for y in range(image.get_height()):
for x in range(image.get_width()):
c = image.get_at((x, y)
neg.set_at((x, y), (255 - color[0], 255 - color[1], 255 - color[2], 255))
return neg