Debian Codegraph @

rgbterm_test.go

raw symbols SCIP
1 package rgbterm_test
2
3 import (
4 "fmt"
5 "github.com/aybabtme/rgbterm"
6 )
7
8 func ExampleBytes() {
9 data := []byte("â–ˆ")
10
11 h, s, l := rgbterm.RGBtoHSL(252, 255, 43)
12 for i := 0; i < 80; i++ {
13 h += (5.0 / 360.0)
14 if h > 1.0 {
15 h = 0.0
16 }
17 r, g, b := rgbterm.HSLtoRGB(h, s, l)
18 fmt.Printf("%s", rgbterm.Bytes(data, r, g, b, 0, 0, 0)) //b, g, r))
19 }
20 fmt.Println()
21
22 // Output:
23 // ████████████████████████████████████████████████████████████████████████████████
24
25 }
26
27 func ExampleBgBytes() {
28 data := []byte(" ")
29
30 h, s, l := rgbterm.RGBtoHSL(252, 255, 43)
31 for i := 0; i < 80; i++ {
32 h += (5.0 / 360.0)
33 if h > 1.0 {
34 h = 0.0
35 }
36 r, g, b := rgbterm.HSLtoRGB(h, s, l)
37 fmt.Printf("%s", rgbterm.BgBytes(data, r, g, b)) //b, g, r))
38 }
39 fmt.Println()
40
41 // Output:
42 //                                                                                 
43
44 }
45
46 func ExampleString() {
47 var r, g, b uint8
48 // pick a color
49 r, g, b = 252, 255, 43
50 // choose a word
51 word := "=)"
52 // colorize it!
53 coloredWord := rgbterm.String(word, r, g, b, 0, 0, 0)
54
55 fmt.Println("Oh!", coloredWord, "hello!")
56
57 // Output:
58 // Oh! =) hello!
59 }