@@ -57,6 +57,7 @@ type RGBColor [4]uint8
57
57
var emptyRGBColor = RGBColor {3 : 99 }
58
58
59
59
// RGB color create.
60
+ //
60
61
// Usage:
61
62
// c := RGB(30,144,255)
62
63
// c := RGB(30,144,255, true)
@@ -106,15 +107,14 @@ func HEX(hex string, isBg ...bool) RGBColor {
106
107
// Hex alias of the HEX()
107
108
func Hex (hex string , isBg ... bool ) RGBColor { return HEX (hex , isBg ... ) }
108
109
110
+ // RGBFromHEX quick RGBColor from hex string, alias of HEX()
111
+ func RGBFromHEX (hex string , isBg ... bool ) RGBColor { return HEX (hex , isBg ... ) }
112
+
109
113
// HSL create RGB color from a hsl value.
110
114
// more see HslToRgb()
111
115
func HSL (h , s , l float64 , isBg ... bool ) RGBColor {
112
- if rgb := HslToRgb (h , s , l ); len (rgb ) > 0 {
113
- return RGB (rgb [0 ], rgb [1 ], rgb [2 ], isBg ... )
114
- }
115
-
116
- // mark is empty
117
- return emptyRGBColor
116
+ rgb := HslToRgb (h , s , l )
117
+ return RGB (rgb [0 ], rgb [1 ], rgb [2 ], isBg ... )
118
118
}
119
119
120
120
// Hsl alias of the HSL()
@@ -123,12 +123,8 @@ func Hsl(h, s, l float64, isBg ...bool) RGBColor { return HSL(h, s, l, isBg...)
123
123
// HSLInt create RGB color from a hsl int value.
124
124
// more see HslIntToRgb()
125
125
func HSLInt (h , s , l int , isBg ... bool ) RGBColor {
126
- if rgb := HslIntToRgb (h , s , l ); len (rgb ) > 0 {
127
- return RGB (rgb [0 ], rgb [1 ], rgb [2 ], isBg ... )
128
- }
129
-
130
- // mark is empty
131
- return emptyRGBColor
126
+ rgb := HslIntToRgb (h , s , l )
127
+ return RGB (rgb [0 ], rgb [1 ], rgb [2 ], isBg ... )
132
128
}
133
129
134
130
// HslInt alias of the HSLInt()
@@ -140,7 +136,7 @@ func RGBFromSlice(rgb []uint8, isBg ...bool) RGBColor {
140
136
}
141
137
142
138
// RGBFromString create RGB color from a string.
143
- // support use color name in the {namedRgbMap}
139
+ // Support use color name in the {namedRgbMap}
144
140
//
145
141
// Usage:
146
142
// c := RGBFromString("170,187,204")
@@ -278,13 +274,13 @@ func (c RGBColor) C16() Color { return c.Basic() }
278
274
* RGB Style
279
275
*************************************************************/
280
276
281
- // RGBStyle definition.
277
+ // RGBStyle supports set foreground and background color
282
278
//
283
- // Foreground/Background color
284
279
// All are composed of 4 digits uint8, the first three digits are the color value;
285
280
// The last bit is different from RGBColor, here it indicates whether the value is set.
286
- // - 1 Has been set
287
- // - ^1 Not set
281
+ //
282
+ // 1 Has been set
283
+ // ^1 Not set
288
284
type RGBStyle struct {
289
285
// Name of the style
290
286
Name string
@@ -305,6 +301,7 @@ func NewRGBStyle(fg RGBColor, bg ...RGBColor) *RGBStyle {
305
301
}
306
302
307
303
// HEXStyle create a RGBStyle from HEX color string.
304
+ //
308
305
// Usage:
309
306
// s := HEXStyle("aabbcc", "eee")
310
307
// s.Print("message")
@@ -317,11 +314,11 @@ func HEXStyle(fg string, bg ...string) *RGBStyle {
317
314
if len (fg ) > 0 {
318
315
s .SetFg (HEX (fg ))
319
316
}
320
-
321
317
return s
322
318
}
323
319
324
320
// RGBStyleFromString create a RGBStyle from color value string.
321
+ //
325
322
// Usage:
326
323
// s := RGBStyleFromString("170,187,204", "70,87,4")
327
324
// s.Print("message")
0 commit comments