from kandinsky import fill_rect from random import * from time import sleep t = 16 w, h = 1 + 320 // t, 1 + 222 // t colors = (247, 23, 53), (6, 123, 194), (255, 194, 71), (59, 216, 159), (129, 207, 229), (246, 84, 169) arr = [choice(colors) for _ in range(w * h)] def init(): for c in range(w): for l in range(h): fill_rect(t * c, t * l, t, t, arr[c + l * w]) def bouge(): u = randint(1, w) v = randint(1, h) c = arr[u * v - 1] i, j = u * t, v * t d = (choice([-1, 1]), choice([-1, 1])) n = 1 + t * randint(1, 3) c1 = [int(c[k] / 1.2) for k in range(3)] c2 = [int(c[k] / 1.5) for k in range(3)] for k in range(n): fill_rect(i, j, t, t, c) fill_rect(i, int(j + (1 - d[1]) * t / 2), t, 1, c1) fill_rect(int(i + (1 - d[0]) * t / 2), j, 1, t, c2) i += d[0] j += d[1] sleep(0.001) init() while True: bouge()