#!/usr/bin/env python3 from math import sin, cos, pi, fmod from time import sleep from random import randint, choice import shutil def print_tc(string, fg, bg): print("\x1b[38;2;{};{};{};48;2;{};{};{}m{}".format(fg[0], fg[1], fg[2], bg[0], bg[1], bg[2], string), end="") bars = [ ' ', '▏', '▎', '▍', '▌', '▋', '▊', '▉'] n = 12 t = 0 while(1): p = 3 + 3*sin(t/300) width = 8 + 8 * shutil.get_terminal_size((80,25))[0] hue = (0.5*(1+cos(t*0.017)), 0.5*(1+sin(t*0.013)), 0.5*(1+sin(t*0.011))) spokes = sorted([int(width/2 + width/2 * -cos(fmod(p+i*pi/n, pi))) for i in range(n)]) + [width] vs = [10 + 245*sin(pi*s/width) for s in spokes] colors = [(int(hue[0]*v), int(hue[1]*v), int(hue[2]*v)) for v in vs] print_tc("\n", colors[0], colors[0]) s = 0 for i in range(8, width, 8): if(spokes[s] >= i): print(' ', end="") else: print_tc(bars[spokes[s]%8], colors[s], colors[s+1]) s += 1 sleep(0.01) t += 1