func BgGray(lightness int) string {
	return Bg(Gray2code(lightness))
}
BgGray converts a scalar of "grayness" to an ANSI-escaped background 8-bit color code
package main
import (
	"fmt"
	"strconv"
	"strings"
)
func Fg(code int) string {
	colored := []string{"\x1b[38;5;", strconv.Itoa(code), "m"}
	return strings.Join(colored, "")
}
func Bg(code int) string {
	colored := []string{"\x1b[48;5;", strconv.Itoa(code), "m"}
	return strings.Join(colored, "")
}
func Rgb2code(r int, g int, b int) int {
	code := 36*r + 6*g + b + 16
	if code < 16 || 231 < code {
		panic(fmt.Errorf("Invalid RGB values (%d, %d, %d)", r, g, b))
	}
	return code
}
func Gray2code(lightness int) int {
	code := lightness + 232
	if code < 232 || 255 < code {
		panic(fmt.Errorf("Invalid lightness value (%d) for gray", lightness))
	}
	return code
}
func FgRGB(r int, g int, b int) string {
	return Fg(Rgb2code(r, g, b))
}
func BgRGB(r int, g int, b int) string {
	return Bg(Rgb2code(r, g, b))
}
func FgGray(lightness int) string {
	return Fg(Gray2code(lightness))
}