Skip to content

Instantly share code, notes, and snippets.

@xjuric29
Created June 7, 2020 12:20
Show Gist options
  • Save xjuric29/4e7d79c3c9fd849840d14976a2b74ca7 to your computer and use it in GitHub Desktop.
Save xjuric29/4e7d79c3c9fd849840d14976a2b74ca7 to your computer and use it in GitHub Desktop.
Very simple linux terminal color fader
with open('ascii.txt', 'r') as f:
text = list(f)
row_len = len(text[1])
colors = [214, 215, 216, 217, 218, 219]
chunk_size = len(colors)
chunk_len = row_len // chunk_size
for line in text:
for i in range(len(colors)):
start = i * chunk_len
to = i * chunk_len + chunk_len
if (i != len(colors) - 1):
#print('DEBUG from: {} to: {}'.format(start, to))
print('\033[38;5;{}m{}'.format(colors[i], line[start:to]), end='')
else:
#print('DEBUG from: {} to: ::'.format(start))
print('\033[38;5;{}m{}'.format(colors[i], line[start::]), end='')
print('\033[0m')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment