#!/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()
    try:
        nc.cursorDisable()
    except RuntimeError:
        print("Couldn't disable cursor")
    for t in range(768):
      print_rgb(nc, t);
    print()

locale.setlocale(locale.LC_ALL, "")
demo()
