package logo import ( "fmt" "strings" ) var version string func SetVersion(v string) { version = v } func GetVersion() string { return version } func GradientText(text string, startColor, endColor string) string { startR, startG, startB := parseHexColor(startColor) endR, endG, endB := parseHexColor(endColor) lines := strings.Split(text, "\n") if len(lines) == 0 { return text } var result []string for _, line := range lines { if len(line) == 0 { result = append(result, line) continue } var coloredLine string for i, char := range line { ratio := float64(i) / float64(len(line)-1) r := int(float64(startR) + float64(endR-startR)*ratio) g := int(float64(startG) + float64(endG-startG)*ratio) b := int(float64(startB) + float64(endB-startB)*ratio) coloredLine += fmt.Sprintf("\033[38;2;%d;%d;%dm%s\033[0m", r, g, b, string(char)) } result = append(result, coloredLine) } return strings.Join(result, "\n") } func parseHexColor(hex string) (int, int, int) { hex = strings.TrimPrefix(hex, "#") if len(hex) != 6 { return 0, 0, 0 } var r, g, b int fmt.Sscanf(hex, "%02x%02x%02x", &r, &g, &b) return r, g, b } func GetLogoPattern() string { return " _ _ _____ _____ " + "\n" + "( \\/ ( _ ( _ ) " + "\n" + " \\ / )(_)( )(_)( " + "\n" + " (__)(_____(_____(" } func GetVersionSuffix() string { v := GetVersion() if v != "" { return " (" + v + " )" } return " ( )" } func PrintLogoWithVersion() { logoPattern := " _ _ _____ _____\n" + "( \\/ ( _ ( _ )\n" + " \\ / )(_)( )(_)( \n" + " (__)(_____(_____(" patternWithVersion := logoPattern + GetVersionSuffix() colored := GradientText(patternWithVersion, "#B413DC", "#00C8C8") fmt.Println(colored) }