Skip to content

Instantly share code, notes, and snippets.

@rsayers
Created May 13, 2024 13:59
Show Gist options
  • Save rsayers/5b1f0bc940c3a3f814b7112b4fd21a10 to your computer and use it in GitHub Desktop.
Save rsayers/5b1f0bc940c3a3f814b7112b4fd21a10 to your computer and use it in GitHub Desktop.
from scrollkit import *
offset = 0
def c(x, y):
factor = WIDTH/2 + (WIDTH/2 * sin(get_time()%50))
v = sin(x / factor) + sin(y / factor)
h = 180 + (180 * v)
h = (h+offset)%360
color = hls_to_rgb(h, 0.5, 0.8)
return color
try:
for lineno in looper:
for x in range(WIDTH):
new_x = (x+lineno) % WIDTH
color = c(x, lineno)
r, g, b = [int(p * 255) for p in color]
print(f'{fg(r, g, b)}\u2588', end='')
offset += 20
print()
sleep(0.02)
except KeyboardInterrupt:
reset()
print("bye!")
from math import sin, cos, acos, tan, pi, e
from colorsys import hls_to_rgb
import shutil
from time import sleep, process_time as get_time
WIDTH = shutil.get_terminal_size().columns
class Looper:
def __init__(self):
self.n = 0
self.end_message = ""
def __iter__(self):
while True:
yield self.n
self.n += 1
def fg(r, g, b):
return f'\033[38;2;{r};{g};{b}m'
def bg(r, g, b):
return f'\033[48;2;{r};{g};{b}m'
def reset():
print('\033[0m')
looper = Looper()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment