summaryrefslogtreecommitdiff
path: root/source.py
blob: 6d0c6f1e36e1a10b0739f8ebd5dbe94d8baef5d7 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# a quick crap script for working with Tremulous's source code
import re

color_vectors = """vec4_t		colorBlack	= {0.000f, 0.000f, 0.000f, 1.000f};
vec4_t		colorRed	= {1.000f, 0.000f, 0.000f, 1.000f};
vec4_t		colorGreen	= {0.000f, 1.000f, 0.000f, 1.000f};
vec4_t		colorBlue	= {0.000f, 0.000f, 1.000f, 1.000f};
vec4_t		colorYellow	= {1.000f, 1.000f, 0.000f, 1.000f};
vec4_t		colorMagenta	= {1.000f, 0.000f, 1.000f, 1.000f};
vec4_t		colorCyan	= {0.000f, 1.000f, 1.000f, 1.000f};
vec4_t		colorWhite	= {1.000f, 1.000f, 1.000f, 1.000f};
vec4_t		colorGray = {0.502f, 0.502f, 0.502f, 1.000f};
vec4_t		colorOrange = {1.000f, 0.686f, 0.000f, 1.000f};
vec4_t		colorRoseBud = {0.996f, 0.671f, 0.604f, 1.000f};
vec4_t		colorPaleGreen = {0.596f, 0.984f, 0.596f, 1.000f};
vec4_t		colorPaleGolden = {0.933f, 0.910f, 0.667f, 1.000f};
vec4_t		colorColumbiaBlue = {0.608f, 0.867f, 1.000f, 1.000f};
vec4_t		colorPaleTurquoise = {0.686f, 0.933f, 0.933f, 1.000f};
vec4_t		colorPaleVioletRed = {0.859f, 0.439f, 0.576f, 1.000f};
vec4_t		colorPalacePaleWhite = {0.910f, 0.898f, 0.863f, 1.000f};
vec4_t		colorOlive = {0.231f, 0.235f, 0.212f, 1.000f};
vec4_t		colorTomato = {1.000f, 0.388f, 0.278f, 1.000f};
vec4_t		colorLime = {0.749f, 1.000f, 0.000f, 1.000f};
vec4_t		colorLemon = {1.000f, 0.969f, 0.000f, 1.000f};
vec4_t		colorBlueBerry = {0.310f, 0.525f, 0.969f, 1.000f};
vec4_t		colorTurquoise = {0.251f, 0.878f, 0.816f, 1.000f};
vec4_t		colorWildWatermelon = {0.992f, 0.357f, 0.471f, 1.000f};
vec4_t		colorSaltpan = {0.933f, 0.953f, 0.898f, 1.000f};
vec4_t		colorGrayChateau = {0.624f, 0.639f, 0.655f, 1.000f};
vec4_t		colorRust = {0.718f, 0.255f, 0.055f, 1.000f};
vec4_t		colorCopperGreen = {0.431f, 0.553f, 0.443f, 1.000f};
vec4_t		colorGold = {1.000f, 0.843f, 0.000f, 1.000f};
vec4_t		colorSteelBlue = {0.275f, 0.510f, 0.706f, 1.000f};
vec4_t		colorSteelGray = {0.482f, 0.565f, 0.584f, 1.000f};
vec4_t		colorBronze = {0.804f, 0.498f, 0.196f, 1.000f};
vec4_t		colorSilver = {0.753f, 0.753f, 0.753f, 1.000f};
vec4_t		colorDarkGray = {0.663f, 0.663f, 0.663f, 1.000f};
vec4_t		colorDarkOrange = {1.000f, 0.549f, 0.000f, 1.000f};
vec4_t		colorDarkGreen = {0.000f, 0.392f, 0.000f, 1.000f};
vec4_t		colorRedOrange = {1.000f, 0.247f, 0.204f, 1.000f};
vec4_t		colorForestGreen = {0.133f, 0.545f, 0.133f, 1.000f};
vec4_t		colorBrightSun = {0.926f, 0.741f, 0.173f, 1.000f};
vec4_t		colorMediumSlateBlue = {0.482f, 0.408f, 0.933f, 1.000f};
vec4_t		colorCeleste = {0.698f, 1.000f, 1.000f, 1.000f};
vec4_t		colorIronstone = {0.525f, 0.314f, 0.251f, 1.000f};
vec4_t		colorTimberwolf = {0.859f, 0.843f, 0.824f, 1.000f};
vec4_t		colorOnyx = {0.059f, 0.059f, 0.059f, 1.000f};
vec4_t		colorRosewood = {0.396f, 0.000f, 0.043f, 1.000f};
vec4_t		colorKokoda = {0.482f, 0.471f, 0.353f, 1.000f};
vec4_t		colorPorsche = {0.875f, 0.616f, 0.357f, 1.000f};
vec4_t		colorCloudBurst = {0.208f, 0.369f, 0.310f, 1.000f};
vec4_t		colorBlueDiane = {0.208f, 0.318f, 0.310f, 1.000f};
vec4_t		colorRope = {0.557f, 0.349f, 0.235f, 1.000f};
vec4_t		colorBlonde = {0.980f, 0.941f, 0.745f, 1.000f};
vec4_t		colorSmokeyBlack = {0.063f, 0.047f, 0.031f, 1.000f};
vec4_t		colorAmericanRose = {1.000f, 0.012f, 0.243f, 1.000f};
vec4_t		colorNeonGreen = {0.224f, 1.000f, 0.078f, 1.000f};
vec4_t		colorNeonYellow = {0.980f, 0.929f, 0.153f, 1.000f};
vec4_t		colorUltramarine = {0.071f, 0.039f, 0.561f, 1.000f};
vec4_t		colorTurquoiseBlue = {0.000f, 1.000f, 0.937f, 1.000f};
vec4_t		colorDarkMagenta = {0.545f, 0.000f, 0.545f, 1.000f};
vec4_t		colorMagicMint = {0.667f, 0.941f, 0.820f, 1.000f};
vec4_t		colorLightGray = {0.827f, 0.827f, 0.827f, 1.000f};
vec4_t		colorLightSalmon = {1.000f, 0.600f, 0.600f, 1.000f};
vec4_t		colorLightGreen = {0.565f, 0.933f, 0.565f, 1.000f};"""

cc_defines = """#define COLOR_BLACK		'0'
#define COLOR_RED		'1'
#define COLOR_GREEN		'2'
#define COLOR_YELLOW	'3'
#define COLOR_BLUE		'4'
#define COLOR_CYAN		'5'
#define COLOR_MAGENTA	'6'
#define COLOR_WHITE		'7'
#define COLOR_GRAY	'8'
#define COLOR_ORANGE	'9'
#define COLOR_ROSE_BUD	'a'
#define COLOR_PALE_GREEN	'b'
#define COLOR_PALE_GOLDEN	'c'
#define COLOR_COLUMBIA_BLUE	'd'
#define COLOR_PALE_TURQUOISE	'e'
#define COLOR_PALE_VIOLET_RED	'f'
#define COLOR_PALACE_PALE_WHITE	'g'
#define COLOR_OLIVE	'h'
#define COLOR_TOMATO	'i'
#define COLOR_LIME	'j'
#define COLOR_LEMON	'k'
#define COLOR_BLUE_BERRY	'l'
#define COLOR_TURQUOISE	'm'
#define COLOR_WILD_WATERMELON	'n'
#define COLOR_SALTPAN	'o'
#define COLOR_GRAY_CHATEAU	'p'
#define COLOR_RUST	'q'
#define COLOR_COPPER_GREEN	'r'
#define COLOR_GOLD	's'
#define COLOR_STEEL_BLUE	't'
#define COLOR_STEEL_GRAY	'u'
#define COLOR_BRONZE	'v'
#define COLOR_SILVER	'w'
#define COLOR_DARK_GRAY	'x'
#define COLOR_DARK_ORANGE	'y'
#define COLOR_DARK_GREEN	'z'
#define COLOR_RED_ORANGE	'A'
#define COLOR_FOREST_GREEN	'B'
#define COLOR_BRIGHT_SUN	'C'
#define COLOR_MEDIUM_SLATE_BLUE	'D'
#define COLOR_CELESTE	'E'
#define COLOR_IRONSTONE	'F'
#define COLOR_TIMBERWOLF	'G'
#define COLOR_ONYX	'H'
#define COLOR_ROSEWOOD	'I'
#define COLOR_KOKODA	'J'
#define COLOR_PORSCHE	'K'
#define COLOR_CLOUD_BURST	'L'
#define COLOR_BLUE_DIANE	'M'
#define COLOR_ROPE	'N'
#define COLOR_BLONDE	'O'
#define COLOR_SMOKEY_BLACK	'P'
#define COLOR_AMERICAN_ROSE	'Q'
#define COLOR_NEON_GREEN	'R'
#define COLOR_NEON_YELLOW	'S'
#define COLOR_ULTRAMARINE	'T'
#define COLOR_TURQUOISE_BLUE	'U'
#define COLOR_DARK_MAGENTA	'V'
#define COLOR_MAGIC_MINT	'W'
#define COLOR_LIGHT_GRAY	'X'
#define COLOR_LIGHT_SALMON	'Y'
#define COLOR_LIGHT_GREEN	'Z'"""

colors = []
for cc in cc_defines.split("\n"):
	rv = re.match("#define\s+COLOR_([A-Z_]+)\s+\'(.)\'", cc)

	name, symbol = rv.groups()
	search = name.replace("_", "").lower()

	for line in color_vectors.split("\n"):
		rv = re.match(".*color([a-zA-Z]+)", line)
		if search != rv.group(1).lower():
			continue

		rv = re.match(".*{(\d+\.\d+)f, (\d+\.\d+)f, (\d+\.\d+)f", line)
		rgb = [float(group) for group in rv.groups()]
		colors.append([symbol, rgb, name.replace("_", " ").lower()])

print("palette_24_bit = [")
for symbol, rgb, name in colors:
	code = "#" + "".join(["%02x" % int(c * 255) for c in rgb])
	print("\t(\"trem %s\", \"%s\", \"black\"), # %s" % (symbol, code, name))
print("]")