This isn't really appropriate for real-time "anaglyphing" as it runs quite slowly (tested with my paticle system). Although, your mileage may vary.
- Code: Select all
import pygame
def anaglyph(source, xoffset):
left = source.copy()
right = source.copy()
surface = pygame.surface.Surface(left.get_size())
left_filter = pygame.surface.Surface(left.get_size())
left_filter.fill((255, 0, 0))
right_filter = pygame.surface.Surface(right.get_size())
right_filter.fill((0, 255, 255))
left.blit(left_filter, (0, 0), None, pygame.BLEND_MULT)
right.blit(right_filter, (0, 0), None, pygame.BLEND_MULT)
surface.blit(left, (0-xoffset, 0), None, pygame.BLEND_ADD)
surface.blit(right, (0+xoffset, 0), None, pygame.BLEND_ADD)
return surface
I tried to make a little utility out of it, but I can't seem to get it to work at the moment.
Original source image

Download link
Resulting anaglyhped image

