notcurses/cffi/notcurses-direct-pydemo

34 lines
619 B
Plaintext
Raw Normal View History

2020-08-30 07:06:06 +00:00
#!/usr/bin/python3
import locale
from notcurses import notcurses
def print_b(nc, r, g, total):
b = total - (r + g)
if b > 255:
return 0
ret = nc.setFgRGB8(r, g, b)
print('X', end='')
def print_gb(nc, r, total):
g = 0
while g <= total - r and g < 256:
print_b(nc, r, g, total)
g += 4
def print_rgb(nc, total):
r = 0
while r < 256 and r < total:
print_gb(nc, r, total)
r += 1
def demo():
nc = notcurses.Ncdirect()
nc.cursorDisable()
2020-08-30 07:06:06 +00:00
for t in range(768):
print_rgb(nc, t);
print()
locale.setlocale(locale.LC_ALL, "")
demo()