bitpwner

Wang Tile Wallpaper Maker

Aug 4th, 2014
942
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Make your wang tile wallpaper.
  2. width     = 32 # Number of blocks horizontally. Maximum 32
  3. height    = 32 # Number of blocks vertically. Maximum 32
  4. blockSize = 64 # Width of block in pixels.
  5. fileName  = "wangtiles.png"
  6. # R,G,B,Y,N = ["755C3B","FCFBE3","FBCFCF","CDBB99","A37E58"]
  7. # R,G,B,Y,N = ["E5EDB8","ADB85F","837B47","5A3D31","300018"]
  8. # R,G,B,Y,N = ["B5AC01","ECBA09","E86E1C","D41E45","1B1521"]
  9. R,G,B,Y,N = ["EFFFCD","DCE9BE","555152","2E2633","99173C"]
  10. # R,G,B,Y,N = ["F7F9FE","ECF1F2","DCE8EB","CBDBE0","BED2D9"]
  11. # Find more colors at http://www.1stwebdesigner.com/freebies/color-palettes-swatches/
  12.  
  13. import Image
  14. R,G,B,Y,N=[((x&0xFF)<<16)|(x&0xFF00)|((x&0xFF0000)>>16)for x in[int(y,16)for y in R,G,B,Y,N]];W=max(32,width);H=max(32,height);u=blockSize;s="RGB";g=[[0,0]]*W*H;k=f=0
  15. def t(c):i=Image.new(s,(2,2));k=i.load();q=u/2;k[1,0],k[1,1],k[0,1],k[0,0]=c;return i.resize([u*2]*2).rotate(45).crop((q,q,q+u,q+u))
  16. l=[map(eval,"GGGRRRYBGGYBGGBBRRGYYNNNNYBGBGBGRGRYRGGRRGGBBYYYYNNN"[z::13])for z in range(13)];g=[l[x]for x in eval("eJytlG0OgyAMQC/UH5T5eZZl97/GxE2Q0pYCRm1KQUOefbwdeJigP66D1wbonwyvY1cjzw6I4TvrQ9kS9+biHkdq87FLPKOLmX3sclzIAOR+ibgOM3a/nuBH0jxlFm+1lPqOjjlmQxUKMMc7Vec4aAxatK+hCBNWSdN8roR2R2m58zdZjkUL28MMpZjIVkWFeRv3f+hTuOws1yVzaigpyiaHrIFlze+QW4hKYoesjWdNb0lhvaY2m5Urr28HUV1w25Gpmd3DtOJ426lpWKCdmha3L1WJr16WW51fJF1Ft/3tHVr+fAGm9bqq".decode("base64").decode("zlib"))]
  17. m=Image.new(s,(W*u,H*u))
  18. for e in g:m.paste(t(e),(f%W*u,(f/W)*u));f+=1
  19. m.save(fileName)
RAW Paste Data