kevinhowbrook
11/13/2017 - 11:06 PM

draw-squares.py

j = 0 # vertical counter
k = 0 # horizontal counter
for i,v in enumerate(convert()):
        if i % squares_per_row == 0 and i != 0: # if i is a multiple of squares per row
            j += 1 # increments after the squares per row is hit like 0,0,0,1,1,1,2,2,2...
        if i % squares_per_row == 0 and i != 0:
            k = 0 # increments after the squares per row is hit like 0,1,2,0,1,2...
        points = ((k*s,j*s), (k*s, j*s+s),(k*s+s,j*s+s),(k*s+s, j*s)) #set points with incrementing values :/
        draw.polygon((points[0], points[1], points[2], points[3]), outline='black',  fill = (v[0],v[1],v[2])) # outline='red', fill='blue'
        #borders so redraw the same plots with white lines
        draw.line((points[0], points[1], points[2], points[3], points[0]),  fill="white", width=border_width) # outline='red', fill='blue'
        k += 1
    im.save('square.jpg') # save the image.