Created
March 16, 2012 10:44
-
-
Save streety/2049532 to your computer and use it in GitHub Desktop.
Cycle through all 16 million possible RGB colors and display them in an image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from PIL import Image | |
| import itertools | |
| import sys | |
| import time | |
| def gen_image(): | |
| im = Image.new('RGB', (4096,4096)) | |
| pix = im.load() | |
| g = itertools.product(range(256), repeat=3) | |
| for i in range(4096): | |
| for j in range(4096): | |
| pix[i,j] = g.next() | |
| return im | |
| def timeit(func): | |
| start = time.time() | |
| result = func() | |
| end = time.time() | |
| print end - start, 's' | |
| return result | |
| if __name__ == '__main__': | |
| im = timeit(gen_image) | |
| im.save(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment