File: rgbterm_test.go

package info (click to toggle)
golang-github-aybabtme-rgbterm 0.0~git20170906.cc83f3b-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 124 kB
  • sloc: makefile: 2
file content (59 lines) | stat: -rw-r--r-- 4,759 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package rgbterm_test

import (
	"fmt"
	"github.com/aybabtme/rgbterm"
)

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:
	// ████████████████████████████████████████████████████████████████████████████████

}

func ExampleBgBytes() {
	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.BgBytes(data, r, g, b)) //b, g, r))
	}
	fmt.Println()

	// Output:
	//                                                                                 

}

func ExampleString() {
	var r, g, b uint8
	// pick a color
	r, g, b = 252, 255, 43
	// choose a word
	word := "=)"
	// colorize it!
	coloredWord := rgbterm.String(word, r, g, b, 0, 0, 0)

	fmt.Println("Oh!", coloredWord, "hello!")

	// Output:
	// Oh! =) hello!
}