coloring/fade-multiple-colors
package main
import (
"strings"
"github.com/pterm/pterm"
)
func main() {
from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
to2 := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients second point.
to3 := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients third point.
to4 := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients end point.
str := "RGB colors only work in Terminals which support TrueColor."
strs := strings.Split(str, "")
var fadeInfo string // String which will be used to print info.
// For loop over the range of the string length.
for i := 0; i < len(str); i++ {
// Append faded letter to info string.
fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
}
// Print info.
pterm.Info.Println(fadeInfo)
// For loop over the range of the terminal height.
for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
// Print string which is colored with the faded RGB value.
from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to, to2, to3, to4).Println("Hello, World!")
}
}