import pygame

def main():
    SIZE = (300, 200)
    WHITE = (255, 255, 255)
    pygame.init()

    # Create a new grayscale surface
    pic = pygame.Surface(SIZE, 0, 8)
    palette = tuple([(i, i, i) for i in range(256)])
    pic.set_palette(palette)

    # Fill it with a gradient
    array = pygame.surfarray.pixels2d(pic)
    factor = 256.0/SIZE[1]
    for i in range(SIZE[1]):
        array[:, i] = int(factor * i)

    # Draw a star on it
    data = (144, 18), (199,166), (63,73), (221, 71), (79,159)
    pygame.draw.lines(pic, WHITE, 1, data)

    # Save the image and quit
    pygame.image.save(pic, 'temp.bmp')
    pygame.quit()

main()

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to