"""Blend blit comparison.

This program shows some differences in colors between the Pygame
and SDL alpha blend. Pygame colors are at top, SDL colors below.
The Pygame colors are a bi lighter. These were generated using 16
bit surfaces with alpha blend. 16 bit surfaces exagerate the
difference because of bit loss. For 32 bit surfaces Pygame differs
by at most +1.

"""

import pygame

#               Pygame                SDL
pairs = [( (132,   0,   0, 255), (123,   0,   0, 255) ),
         ( (132, 125  , 0, 255), (123, 125,   0, 255) ),
         ( (132,   0, 123, 255), (123,   0, 123, 255) ),
         ( (132, 125, 123, 255), (123, 125, 123, 255) ),
         ( (  0, 130,   0, 255), (  0, 125,   0, 255) ),
         ( (123, 130,   0, 255), (123, 125,   0, 255) ),
         ( (  0, 130, 123, 255), (  0, 125, 123, 255) ),
         ( (123, 130, 123, 255), (123, 125, 123, 255) ),
         ( (  0,   0, 132, 255), (  0,   0, 123, 255) ),
         ( (123,   0, 132, 255), (123,   0, 123, 255) ),
         ( (  0, 125, 132, 255), (  0, 125, 123, 255) ),
         ( (123, 125, 132, 255), (123, 125, 123, 255) )]

s = pygame.Surface((600, 320), 0, 32)
s.fill((255, 255, 255))
for i in range(12):
    pyg_col, sdl_col = pairs[i]
    x = 50 * i + 5
    s.fill(pyg_col, (x, 10, 40, 150))   # Pygame
    s.fill(sdl_col, (x, 160, 40, 150))  # SDL


pygame.init()
try:
    screen = pygame.display.set_mode(s.get_size())
    screen.blit(s, (0, 0))
    pygame.display.flip()
    while (1):
        e = pygame.event.wait()
        if (e.type == pygame.QUIT):
            break
        elif (e.type == pygame.KEYDOWN):
            break

finally:
    pygame.quit()


