We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b791093 commit e245e6bCopy full SHA for e245e6b
pkg/color/color.go
@@ -1,15 +1,31 @@
1
package color
2
3
import (
4
+ "fmt"
5
+ "image/color"
6
+
7
"github.com/hinshun/vt10x"
8
)
9
10
//go:generate go run colorsgen.go
11
12
func GetColor(c vt10x.Color) string {
- if c >= 1<<24 {
13
+ switch {
14
+ case c >= 1<<24:
15
return colors[int(vt10x.LightGrey)]
16
+ case c >= 1<<8:
17
+ rgb := intToRGB(int(c))
18
+ return fmt.Sprintf("#%02x%02x%02x", rgb.R, rgb.B, rgb.G)
19
+ default:
20
+ return colors[int(c)]
21
}
22
+}
23
- return colors[int(c)]
24
+func intToRGB(c int) color.RGBA {
25
+ return color.RGBA{
26
+ R: uint8(c >> 16),
27
+ G: uint8(c >> 8),
28
+ B: uint8(c),
29
+ A: 255,
30
+ }
31
0 commit comments