Skip to content

Instantly share code, notes, and snippets.

@Mrestof
Created August 23, 2019 23:40
Show Gist options
  • Save Mrestof/de68f8fddc8bd5b8924e8aa6b9a5e9bf to your computer and use it in GitHub Desktop.
Save Mrestof/de68f8fddc8bd5b8924e8aa6b9a5e9bf to your computer and use it in GitHub Desktop.
Small script for animated loading. (without any graphics modules)
import time
display = [[0 for columns in range(10)] for rows in range(6)]
def draw(freq: float = 0.05):
to_print = ''
time.sleep(freq)
print('\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n')
for line in display:
for item in line:
to_print += '#' if item == 1 else '.'
print(to_print)
to_print = ''
def go_circle(lu: list, ld: list, rd: list, ru: list, tail: int = 1):
dot = list(lu)
dot_stack = []
while dot != ld:
dot[0] += 1
display[dot[0]][dot[1]] = 1
dot_stack.append(list(dot))
draw(0.083)
if len(dot_stack) == tail:
dot_to_delete = dot_stack.pop(0)
display[dot_to_delete[0]][dot_to_delete[1]] = 0
while dot != rd:
dot[1] += 1
display[dot[0]][dot[1]] = 1
dot_stack.append(list(dot))
draw()
if len(dot_stack) == tail:
dot_to_delete = dot_stack.pop(0)
display[dot_to_delete[0]][dot_to_delete[1]] = 0
while dot != ru:
dot[0] -= 1
display[dot[0]][dot[1]] = 1
dot_stack.append(list(dot))
draw(0.083)
if len(dot_stack) == tail:
dot_to_delete = dot_stack.pop(0)
display[dot_to_delete[0]][dot_to_delete[1]] = 0
while dot != lu:
dot[1] -= 1
display[dot[0]][dot[1]] = 1
dot_stack.append(list(dot))
draw()
if len(dot_stack) == tail:
dot_to_delete = dot_stack.pop(0)
display[dot_to_delete[0]][dot_to_delete[1]] = 0
while len(dot_stack):
dot_to_delete = dot_stack.pop(0)
display[dot_to_delete[0]][dot_to_delete[1]] = 0
draw()
while 1:
go_circle([0, 0], [5, 0], [5, 9], [0, 9], 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment