Home About Random
w = 40
h = 40

grid = BlockGrid(w, h)

for block in grid:
    block.size = min(abs(w / 2 - block.col), abs(h / 2 - block.row))
    
    if block.row < h / 2 and block.col < w / 2:
        val = max(block.row, block.col) / (w / 2.) * 255
        block.set_colors(val, val, val)
    
    elif block.row < h / 2 and block.col >= w / 2:
        val = max(block.row, h - block.col - 1) / (w / 2.) * 255
        block.set_colors(val, val, 255)
    
    elif block.row >= h / 2 and block.col < w / 2:
        val = max(w - block.row - 1, block.col) / (w / 2.) * 255
        block.set_colors(255, val, val)
    
    elif block.row >= h / 2 and block.col >= w / 2:
        val = max(w - block.row - 1, h - block.col - 1) / (w / 2.) * 255
        block.set_colors(val, 255, val)

grid.post_to_web(6)