# animation for medium article

from termcolor import colored
import time
import imageio
import pyautogui

pyautogui.FAILSAFE = True

matrix = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 2, 2, 2, 0, 0, 0],
          [0, 0, 0, 0, 0, 2, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          [1, 0, 1, 1, 1, 1, 1, 1, 1, 0],
          [1, 0, 1, 0, 0, 0, 0, 1, 0, 1],
          [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
          [0, 1, 0, 1, 0, 1, 0, 0, 1, 1],
          [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]

lst = set()
for i in range(21):
    for z in range(10):
        for row in range(len(matrix)):
            if 0 not in matrix[row]:
                lst.add(row)
            if (i == 20 or i > row) and row in lst:
                print(colored("1 " * 10, "green"))
            else:
                for element in range(len(matrix[row])):
                    if i == row and z == element:
                        print(colored(matrix[row][element], "green"), end=" ", flush=False)
                    elif matrix[row][element] == 1:
                        print(colored(matrix[row][element], "red"), end=" ", flush=False)
                    elif matrix[row][element] == 2:
                        print(colored(matrix[row][element], "blue"), end=" ", flush=False)
                    else:
                        print(matrix[row][element], end=" ", flush=False)
                print("")
        print("")
        # takes a screenshot
        pyautogui.moveTo(338, 580, duration = 0)
        pyautogui.hotkey('command', 'shift', '4')
        pyautogui.dragTo(547, 1000, duration = 0, button = 'left')

[((52, 8, 52, 48), 'pyautogui.moveTo', 'pyautogui.moveTo', (), '', False, 'import pyautogui\n'), ((53, 8, 53, 49), 'pyautogui.hotkey', 'pyautogui.hotkey', ({(53, 25, 53, 34): '"""command"""', (53, 36, 53, 43): '"""shift"""', (53, 45, 53, 48): '"""4"""'}, {}), "('command', 'shift', '4')", False, 'import pyautogui\n'), ((54, 8, 54, 66), 'pyautogui.dragTo', 'pyautogui.dragTo', (), '', False, 'import pyautogui\n'), ((38, 22, 38, 49), 'termcolor.colored', 'colored', ({(38, 30, 38, 39): "('1 ' * 10)", (38, 41, 38, 48): '"""green"""'}, {}), "('1 ' * 10, 'green')", False, 'from termcolor import colored\n'), ((42, 30, 42, 68), 'termcolor.colored', 'colored', ({(42, 38, 42, 58): 'matrix[row][element]', (42, 60, 42, 67): '"""green"""'}, {}), "(matrix[row][element], 'green')", False, 'from termcolor import colored\n'), ((44, 30, 44, 66), 'termcolor.colored', 'colored', ({(44, 38, 44, 58): 'matrix[row][element]', (44, 60, 44, 65): '"""red"""'}, {}), "(matrix[row][element], 'red')", False, 'from termcolor import colored\n'), ((46, 30, 46, 67), 'termcolor.colored', 'colored', ({(46, 38, 46, 58): 'matrix[row][element]', (46, 60, 46, 66): '"""blue"""'}, {}), "(matrix[row][element], 'blue')", False, 'from termcolor import colored\n')]