func HexToRGB(hex string) (rgb []int) {
	hex = strings.TrimSpace(hex)
	if hex == "" {
		return
	}
	if hex[0] == '#' {
		hex = hex[1:]
	}
	hex = strings.ToLower(hex)
	switch len(hex) {
	case 3:  
		hex = string([]byte{hex[0], hex[0], hex[1], hex[1], hex[2], hex[2]})
	case 8:  
		hex = strings.TrimPrefix(hex, "0x")
	}
	if len(hex) != 6 {
		return
	}
	if i64, err := strconv.ParseInt(hex, 16, 32); err == nil {
		color := int(i64)
		rgb = make([]int, 3)
		rgb[0] = color >> 16
		rgb[1] = (color & 0x00FF00) >> 8
		rgb[2] = color & 0x0000FF
	}
	return
}
HexToRGB hex color string to RGB numbers
Usage:
rgb := HexToRGB("ccc") // rgb: [204 204 204]
rgb := HexToRGB("aabbcc") // rgb: [170 187 204]
rgb := HexToRGB("#aabbcc") // rgb: [170 187 204]
rgb := HexToRGB("0xad99c0") // rgb: [170 187 204]
package color
import (
	"fmt"
	"strconv"
	"strings"
)
const (
	TplFgRGB = "38;2;%d;%d;%d"
	TplBgRGB = "48;2;%d;%d;%d"
)
const (
	AsFg uint8 = iota
	AsBg
)
type RGBColor [4]uint8
var emptyRGBColor = RGBColor{3: 99}
func RGB(r, g, b uint8, isBg ...bool) RGBColor {
	rgb := RGBColor{r, g, b}
	if len(isBg) > 0 && isBg[0] {
		rgb[3] = AsBg
	}
	return rgb
}
func HEX(hex string, isBg ...bool) RGBColor {
	if rgb := HexToRGB(hex); len(rgb) > 0 {
		return RGB(uint8(rgb[0]), uint8(rgb[1]), uint8(rgb[2]), isBg...)
	}
	return emptyRGBColor
}
func RGBFromString(rgb string, isBg ...bool) RGBColor {
	ss := stringToArr(rgb, ",")
	if len(ss) != 3 {
		return emptyRGBColor
	}
	var ar [3]int
	for i, val := range ss {
		iv, err := strconv.Atoi(val)
		if err != nil {
			return emptyRGBColor
		}
		ar[i] = iv
	}
	return RGB(uint8(ar[0]), uint8(ar[1]), uint8(ar[2]), isBg...)
}
func (c RGBColor) Print(a ...interface{}) {
	fmt.Print(RenderCode(c.String(), a...))
}
func (c RGBColor) Printf(format string, a ...interface{}) {
	fmt.Print(RenderString(c.String(), fmt.Sprintf(format, a...)))
}
func (c RGBColor) Println(a ...interface{}) {
	fmt.Println(RenderCode(c.String(), a...))
}
func (c RGBColor) Sprint(a ...interface{}) string {
	return RenderCode(c.String(), a...)
}
func (c RGBColor) Sprintf(format string, a ...interface{}) string {
	return RenderString(c.String(), fmt.Sprintf(format, a...))
}
func (c RGBColor) Values() []int {
	return []int{int(c[0]), int(c[1]), int(c[2])}
}
func (c RGBColor) String() string {
	if c[3] == AsFg {  
		return fmt.Sprintf(TplFgRGB, c[0], c[1], c[2])
	}
	if c[3] == AsBg {  
		return fmt.Sprintf(TplBgRGB, c[0], c[1], c[2])
	}
	return ""
}
func (c RGBColor) IsEmpty() bool {
	return c[3] > 1
}