blob: 2b13c9236f5914b648da9e500c4db05445e0dc44 (
plain)
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
|
package style
import "github.com/gookit/color"
type Color struct {
rgb *color.RGBColor
basic *color.Color
}
func NewRGBColor(cl color.RGBColor) Color {
c := Color{}
c.rgb = &cl
return c
}
func NewBasicColor(cl color.Color) Color {
c := Color{}
c.basic = &cl
return c
}
func (c Color) IsRGB() bool {
return c.rgb != nil
}
func (c Color) ToRGB(isBg bool) Color {
if c.IsRGB() {
return c
}
if isBg {
// We need to convert bg color to fg color
// This is a gookit/color bug,
// https://github.com/gookit/color/issues/39
return NewRGBColor((*c.basic - 10).RGB())
}
return NewRGBColor(c.basic.RGB())
}
|