-
-
Notifications
You must be signed in to change notification settings - Fork 286
/
color.go
61 lines (57 loc) · 1.02 KB
/
color.go
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package game
// Color : Int constant mapping
const (
Red = 0
Blue = 1
Green = 2
Pink = 3
Orange = 4
Yellow = 5
Black = 6
White = 7
Purple = 8
Brown = 9
Cyan = 10
Lime = 11
Maroon = 12
Rose = 13
Banana = 14
Gray = 15
Tan = 16
Coral = 17
)
// ColorStrings for lowercase, possibly for translation if needed
var ColorStrings = map[string]int{
"red": Red,
"blue": Blue,
"green": Green,
"pink": Pink,
"orange": Orange,
"yellow": Yellow,
"black": Black,
"white": White,
"purple": Purple,
"brown": Brown,
"cyan": Cyan,
"lime": Lime,
"maroon": Maroon,
"rose": Rose,
"banana": Banana,
"gray": Gray,
"tan": Tan,
"coral": Coral,
}
// GetColorStringForInt does what it sounds like
func GetColorStringForInt(colorint int) string {
for str, idx := range ColorStrings {
if idx == colorint {
return str
}
}
return ""
}
// IsColorString determines if a string is actually one of our colors
func IsColorString(test string) bool {
_, ok := ColorStrings[test]
return ok
}