Skip to content

Instantly share code, notes, and snippets.

@robinhouston
Created March 4, 2014 21:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinhouston/9355549 to your computer and use it in GitHub Desktop.
Save robinhouston/9355549 to your computer and use it in GitHub Desktop.
A 4096×4096 image containing each RGB value once (h/t allrgb.com). Z-order traversal of RGB cube mapped to z-order traversal of 4096×4096 square.
from PIL import Image
def splitnum(k, x):
parts = [0] * k
for n in range(24):
parts[n % k] |= ((x >> n) & 1) << (n // k)
return tuple(parts)
im = Image.new("RGB", (4096, 4096))
pix = im.load()
for n in range(2**24):
pix[splitnum(2, n)] = splitnum(3, n)
im.save("the-universal-tartan.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment