from kandinsky import * from math import log2 from time import * N = (0,0,0) def grille(d): t = int(log2(d)) dx, dy = [0,1,0,1], [0,1,1,0] arr = [[0 for _ in range(d)] for _ in range(d)] for n in range(d * d): v = n col, lig = 0, 0 for i in range(t): r, p = v % 4, t - i - 1 col += dx[r] * 2 ** p lig += dy[r] * 2 ** p v //= 4 arr[lig][col] = n return sum(arr, []) def grey(): t = 32 arr = grille(t) for i in range(t * t): p = arr.index(i) x, y = p % t, p // t fill_rect(5 * x, 1 + 5 * y, 5, 5, N) fill_rect(5 * x + 160, 1 + 5 * y, 5, 5, N) if y < 12: fill_rect(5 * x, 5 * y + 161, 5, 5, N) fill_rect(5 * x + 160, 5 * y + 161, 5, 5, N) sleep(.01) grey()