Example #1
0
func ExampleBytes() {
	data := []byte("â–ˆ")

	h, s, l := rgbterm.RGBtoHSL(252, 255, 43)
	for i := 0; i < 80; i++ {
		h += (5.0 / 360.0)
		if h > 1.0 {
			h = 0.0
		}
		r, g, b := rgbterm.HSLtoRGB(h, s, l)
		fmt.Printf("%s", rgbterm.Bytes(data, r, g, b))
	}
	fmt.Println()

	// Output:
	// ████████████████████████████████████████████████████████████████████████████████

}
Example #2
0
func ExampleBytes() {
	data := []byte("â–ˆ")

	h, s, l := rgbterm.RGBtoHSL(252, 255, 43)
	for i := 0; i < 80; i++ {
		h += (5.0 / 360.0)
		if h > 1.0 {
			h = 0.0
		}
		r, g, b := rgbterm.HSLtoRGB(h, s, l)
		fmt.Printf("%s", rgbterm.Bytes(data, r, g, b, 0, 0, 0)) //b, g, r))
	}
	fmt.Println()

	// Output:
	// ████████████████████████████████████████████████████████████████████████████████

}
Example #3
0
// New creates a Rainbow writer, wrapping each byte with a new color
// of the rainbow. This is clearly a good idea! This is especially
// useful when w is something like a net.Conn or the output of a log.
func New(w io.Writer, r, g, b uint8) *Rainbow {
	h, s, l := rgbterm.RGBtoHSL(r, g, b)
	return &Rainbow{wrap: w, h: h, s: s, l: l}
}