Code by Abe Dillon
       canvas.py                              PDF


       __author__ = 'adillon'

       from PIL import Image, ImageChops
       import os

       v = [0,0,0,0]
       h = [0,0,0,0,0,0]
       m = [2,2,2]

       t = 4
       w = 128
           ( t, t, t*2+w*2, t*4+w*4)]

       ver = [(t+w,t,t*2+w,t*2+w),
           ((t+w,t+w,t*2+w,t*3+w*2),
           ((t+w,t*2+w*2,t*2+w,t*4+w*3),
           ((t+w,t*3+w*3,t*2+w,t*4+w*4)]

       hor = [(t,t+w,t*2+w,t*2+w),
           (t+w,t+w,t*2+w*2,t*2+w),
           (t,t*2+w*2,t*2+w,t*3+w*2),
           (t+w,t*2+w*2,t*2+w*2,t*3+w*2),
           (t,t*3+w*3,t*2+w,t*4+w*3),
           (t+w,t*3+w*3,t*2+w*2,t*4+w*3)]

       lookup = {2: ((0,0),(1,1)),
           3: ((0,1),(1,0),(1,1)),
           4: ((0,0),(0,1),(1,0),(1,1))}

       bimg = Image.new("1", (can[0][2], can[0][3]))
       wimg = bimg.crop(can[1])
       wimg = ImageChops.invert(wimg)
       bimg.paste(wimg,can[1])

       for n in range(16):
           vert_str = bin(n)[2:]
           vert_str = "0"*(4-len(vert_str)) + vert_str
           for i, c in enumerate(vert_str):
                v[i] = int(c)

       for p in range(3):
           if (v[p],v[p+1]) == (0,0):
                m[p] = 2
           if (v[p],v[p+1]) in {(1,0),(0,1)}:
                m[p] = 3
           if (v[p],v[p+1]) == (1,1):
                m[p] = 4

       mx = [0,0,0]
       done = False
       while not done:

           h[0], h[1] = lookup[m[0]][mx[0]]
           h[2], h[3] = lookup[m[1]][mx[1]]
           h[4], h[5] = lookup[m[2]][mx[2]]

           oimg = bimg.copy()
           for vdex, v_line in enumerate(v):
               if v_line == 1:
                   oimg.paste(0, ver[vdex])
           for hdex, h_line in enumerate(h):
               if h_line == 1:
                   oimg.paste(0, hor[hdex])

           mx_str = ''.join([str(a) for a in mx])

           oimg.save(os.getcwd() + "\\Noah\\" + vert_str + "_" + mx_str + ".png")

           mx[0] += 1
           if mx[0] == m[0]:
               mx[0] = 0
               mx[1] += 1

           if mx[1] == m[1]:
               mx[1] = 0
               mx[2] += 1

           if mx[2] == m[2]:
               done = True