@@ -19,17 +19,7 @@ Color :: struct {
19
19
type: union {No_Color, ANSI_Color, ANSI256_Color, RGB_Color},
20
20
}
21
21
22
- // create a new colorful hex color
23
- // TODO: Add colorful.Color to API above?
24
- // May be confusing becase RGB_Color is a hex string internally
25
- // while a colorful.Color is abtually defined (r,g,b)
26
- // Define an RGB color with (r,g,b) too?
27
- new_hex_color :: proc (s: string ) -> (color: colorful.Color) {
28
- color, _ = colorful.hex (s)
29
- return
30
- }
31
-
32
- // No_Color is a nop for terminals that don't support colors.
22
+ // No_Color for terminals that don't support colors.
33
23
No_Color :: struct {
34
24
using clr: ^Color,
35
25
}
@@ -41,10 +31,6 @@ new_no_color :: proc() -> ^Color {
41
31
return color
42
32
}
43
33
44
- no_color_string :: proc (c: No_Color) -> string {
45
- return " "
46
- }
47
-
48
34
// ANSI is a color (0-15) as defined by the ANSI Standard.
49
35
ANSI_Color :: struct {
50
36
using clr: ^Color,
@@ -58,10 +44,6 @@ new_ansi_color :: proc(c: int) -> ^Color {
58
44
return color
59
45
}
60
46
61
- ansi_string :: proc (c: ANSI_Color) -> (str: string ) {
62
- return c.color
63
- }
64
-
65
47
// ANSI256_Color is a color (16-255) as defined by the ANSI Standard.
66
48
ANSI256_Color :: struct {
67
49
using clr: ^Color,
@@ -75,10 +57,6 @@ new_ansi256_color :: proc(c: int) -> ^Color {
75
57
return color
76
58
}
77
59
78
- ansi256_string :: proc (c: ANSI256_Color) -> (str: string ) {
79
- return c.color
80
- }
81
-
82
60
// RGB is a hex-encoded color, e.g. "#abcdef".
83
61
RGB_Color :: struct {
84
62
using clr: ^Color,
@@ -92,8 +70,8 @@ new_rgb_color :: proc(c: string) -> ^Color {
92
70
return color
93
71
}
94
72
95
- // ConvertToRGB converts a Color to a colorful.Color.
96
- convert_to_hex :: proc (c: ^Color) -> colorful.Color {
73
+ // Converts a Color to an rgb colorful.Color.
74
+ convert_to_rgb :: proc (c: ^Color) -> colorful.Color {
97
75
hex: string
98
76
switch v in c.type {
99
77
case RGB_Color:
@@ -110,7 +88,7 @@ convert_to_hex :: proc(c: ^Color) -> colorful.Color {
110
88
return ch
111
89
}
112
90
113
- // returns a hex string from a color
91
+ // returns a hex string from an rgb color
114
92
hex :: proc (c: colorful.Color) -> string {
115
93
return colorful.color_hex (c)
116
94
}
@@ -234,9 +212,9 @@ ansi256_to_ansi :: proc(c: ANSI256_Color) -> ^Color {
234
212
r: int
235
213
md := math.F64_MAX
236
214
237
- h, _ := colorful.hex (ansi_hex[c.c] )
215
+ h, _ := colorful.hex (c.color )
238
216
for i := 0 ; i <= 15 ; i += 1 {
239
- hb, _ := colorful.hex (ansi_hex[c.c ])
217
+ hb, _ := colorful.hex (ansi_hex[i ])
240
218
d := colorful.distance_hsluv (h, hb)
241
219
242
220
if d < md {
0 commit comments