Skip to content

Instantly share code, notes, and snippets.

@HactarCE
Created October 6, 2025 00:21
Show Gist options
  • Save HactarCE/d22871987c0db470687c2c0d64278394 to your computer and use it in GitHub Desktop.
Save HactarCE/d22871987c0db470687c2c0d64278394 to your computer and use it in GitHub Desktop.
Terminal loading animation using Braille patterns

Inspired by the animation when using gh run download

#!/usr/bin/env python3
import time
DELAY = 1/20
dot_order = [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (0, 3), (1, 3)]
coordinates = set()
def toggle(pos):
if pos in coordinates:
coordinates.remove(pos)
else:
coordinates.add(pos)
def br(x0, y0):
bits = sum(((x0+x, y0+y) in coordinates) << i for (i, (x, y)) in enumerate(dot_order))
return chr(0x2800 + bits)
def update():
print(f'\r{br(0, 0)}{br(2, 0)} ', end='')
loop = [(2, 0), (3, 0), (3, 1), (3, 2), (3, 3), (2, 3), (1, 3), (0, 3), (0, 2), (0, 1), (0, 0), (1, 0)]
length = 6
for pos in loop[:length]:
toggle(pos)
try:
while True:
for i in range(len(loop)):
toggle(loop[i % len(loop)])
toggle(loop[(i+length) % len(loop)])
update()
time.sleep(DELAY)
except KeyboardInterrupt:
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment