1
+ from __future__ import annotations
1
2
import random
2
3
import re
3
4
from collections import namedtuple
4
- from typing import Dict , Tuple , List
5
5
6
6
Color = namedtuple ('Color' , ' R G B' )
7
7
8
- tunic_colors : Dict [str , Color ] = {
8
+ tunic_colors : dict [str , Color ] = {
9
9
"Kokiri Green" : Color (0x1E , 0x69 , 0x1B ),
10
10
"Goron Red" : Color (0x64 , 0x14 , 0x00 ),
11
11
"Zora Blue" : Color (0x00 , 0x3C , 0x64 ),
40
40
}
41
41
42
42
# Inner Core Color Outer Glow Color
43
- NaviColors : Dict [str , Tuple [Color , Color ]] = {
43
+ NaviColors : dict [str , tuple [Color , Color ]] = {
44
44
"Rainbow" : (Color (0x00 , 0x00 , 0x00 ), Color (0x00 , 0x00 , 0x00 )),
45
45
"Gold" : (Color (0xFE , 0xCC , 0x3C ), Color (0xFE , 0xC0 , 0x07 )),
46
46
"White" : (Color (0xFF , 0xFF , 0xFF ), Color (0x00 , 0x00 , 0xFF )),
63
63
"Phantom Zelda" : (Color (0x97 , 0x7A , 0x6C ), Color (0x6F , 0x46 , 0x67 )),
64
64
}
65
65
66
- sword_trail_colors : Dict [str , Color ] = {
66
+ sword_trail_colors : dict [str , Color ] = {
67
67
"Rainbow" : Color (0x00 , 0x00 , 0x00 ),
68
68
"White" : Color (0xFF , 0xFF , 0xFF ),
69
69
"Red" : Color (0xFF , 0x00 , 0x00 ),
77
77
"Pink" : Color (0xFF , 0x69 , 0xB4 ),
78
78
}
79
79
80
- bombchu_trail_colors : Dict [str , Color ] = {
80
+ bombchu_trail_colors : dict [str , Color ] = {
81
81
"Rainbow" : Color (0x00 , 0x00 , 0x00 ),
82
82
"Red" : Color (0xFA , 0x00 , 0x00 ),
83
83
"Green" : Color (0x00 , 0xFF , 0x00 ),
90
90
"Pink" : Color (0xFF , 0x69 , 0xB4 ),
91
91
}
92
92
93
- boomerang_trail_colors : Dict [str , Color ] = {
93
+ boomerang_trail_colors : dict [str , Color ] = {
94
94
"Rainbow" : Color (0x00 , 0x00 , 0x00 ),
95
95
"Yellow" : Color (0xFF , 0xFF , 0x64 ),
96
96
"Red" : Color (0xFF , 0x00 , 0x00 ),
104
104
"Pink" : Color (0xFF , 0x69 , 0xB4 ),
105
105
}
106
106
107
- gauntlet_colors : Dict [str , Color ] = {
107
+ gauntlet_colors : dict [str , Color ] = {
108
108
"Silver" : Color (0xFF , 0xFF , 0xFF ),
109
109
"Gold" : Color (0xFE , 0xCF , 0x0F ),
110
110
"Black" : Color (0x00 , 0x00 , 0x06 ),
120
120
"Purple" : Color (0x80 , 0x00 , 0x80 ),
121
121
}
122
122
123
- shield_frame_colors : Dict [str , Color ] = {
123
+ shield_frame_colors : dict [str , Color ] = {
124
124
"Red" : Color (0xD7 , 0x00 , 0x00 ),
125
125
"Green" : Color (0x00 , 0xFF , 0x00 ),
126
126
"Blue" : Color (0x00 , 0x40 , 0xD8 ),
133
133
"Pink" : Color (0xFF , 0x69 , 0xB4 ),
134
134
}
135
135
136
- heart_colors : Dict [str , Color ] = {
136
+ heart_colors : dict [str , Color ] = {
137
137
"Red" : Color (0xFF , 0x46 , 0x32 ),
138
138
"Green" : Color (0x46 , 0xC8 , 0x32 ),
139
139
"Blue" : Color (0x32 , 0x46 , 0xFF ),
140
140
"Yellow" : Color (0xFF , 0xE0 , 0x00 ),
141
141
}
142
142
143
- magic_colors : Dict [str , Color ] = {
143
+ magic_colors : dict [str , Color ] = {
144
144
"Green" : Color (0x00 , 0xC8 , 0x00 ),
145
145
"Red" : Color (0xC8 , 0x00 , 0x00 ),
146
146
"Blue" : Color (0x00 , 0x30 , 0xFF ),
152
152
153
153
# A Button Text Cursor Shop Cursor Save/Death Cursor
154
154
# Pause Menu A Cursor Pause Menu A Icon A Note
155
- a_button_colors : Dict [str , Tuple [Color , Color , Color , Color , Color , Color , Color ]] = {
155
+ a_button_colors : dict [str , tuple [Color , Color , Color , Color , Color , Color , Color ]] = {
156
156
"N64 Blue" : (Color (0x5A , 0x5A , 0xFF ), Color (0x00 , 0x50 , 0xC8 ), Color (0x00 , 0x50 , 0xFF ), Color (0x64 , 0x64 , 0xFF ),
157
157
Color (0x00 , 0x32 , 0xFF ), Color (0x00 , 0x64 , 0xFF ), Color (0x50 , 0x96 , 0xFF )),
158
158
"N64 Green" : (Color (0x00 , 0x96 , 0x00 ), Color (0x00 , 0x96 , 0x00 ), Color (0x00 , 0x96 , 0x00 ), Color (0x64 , 0x96 , 0x64 ),
188
188
}
189
189
190
190
# B Button
191
- b_button_colors : Dict [str , Color ] = {
191
+ b_button_colors : dict [str , Color ] = {
192
192
"N64 Blue" : Color (0x5A , 0x5A , 0xFF ),
193
193
"N64 Green" : Color (0x00 , 0x96 , 0x00 ),
194
194
"N64 Red" : Color (0xC8 , 0x00 , 0x00 ),
208
208
}
209
209
210
210
# C Button Pause Menu C Cursor Pause Menu C Icon C Note
211
- c_button_colors : Dict [str , Tuple [Color , Color , Color , Color ]] = {
211
+ c_button_colors : dict [str , tuple [Color , Color , Color , Color ]] = {
212
212
"N64 Blue" : (Color (0x5A , 0x5A , 0xFF ), Color (0x00 , 0x32 , 0xFF ), Color (0x00 , 0x64 , 0xFF ), Color (0x50 , 0x96 , 0xFF )),
213
213
"N64 Green" : (Color (0x00 , 0x96 , 0x00 ), Color (0x00 , 0x96 , 0x00 ), Color (0x00 , 0x96 , 0x00 ), Color (0x00 , 0x96 , 0x00 )),
214
214
"N64 Red" : (Color (0xC8 , 0x00 , 0x00 ), Color (0xC8 , 0x00 , 0x00 ), Color (0xC8 , 0x00 , 0x00 ), Color (0xC8 , 0x00 , 0x00 )),
228
228
}
229
229
230
230
# Start Button
231
- start_button_colors : Dict [str , Color ] = {
231
+ start_button_colors : dict [str , Color ] = {
232
232
"N64 Blue" : Color (0x5A , 0x5A , 0xFF ),
233
233
"N64 Green" : Color (0x00 , 0x96 , 0x00 ),
234
234
"N64 Red" : Color (0xC8 , 0x00 , 0x00 ),
247
247
"Orange" : Color (0xFF , 0x80 , 0x00 ),
248
248
}
249
249
250
- meta_color_choices : List [str ] = ["Random Choice" , "Completely Random" , "Custom Color" ]
250
+ meta_color_choices : list [str ] = ["Random Choice" , "Completely Random" , "Custom Color" ]
251
251
252
252
253
- def get_tunic_colors () -> List [str ]:
253
+ def get_tunic_colors () -> list [str ]:
254
254
return list (tunic_colors .keys ())
255
255
256
256
257
- def get_tunic_color_options () -> List [str ]:
257
+ def get_tunic_color_options () -> list [str ]:
258
258
return meta_color_choices + ["Rainbow" ] + get_tunic_colors ()
259
259
260
260
261
- def get_navi_colors () -> List [str ]:
261
+ def get_navi_colors () -> list [str ]:
262
262
return list (NaviColors .keys ())
263
263
264
264
265
- def get_navi_color_options (outer : bool = False ) -> List [str ]:
265
+ def get_navi_color_options (outer : bool = False ) -> list [str ]:
266
266
if outer :
267
267
return ["[Same as Inner]" ] + meta_color_choices + get_navi_colors ()
268
268
else :
269
269
return meta_color_choices + get_navi_colors ()
270
270
271
271
272
- def get_sword_trail_colors () -> List [str ]:
272
+ def get_sword_trail_colors () -> list [str ]:
273
273
return list (sword_trail_colors .keys ())
274
274
275
275
276
- def get_sword_trail_color_options (outer : bool = False ) -> List [str ]:
276
+ def get_sword_trail_color_options (outer : bool = False ) -> list [str ]:
277
277
if outer :
278
278
return ["[Same as Inner]" ] + meta_color_choices + get_sword_trail_colors ()
279
279
else :
280
280
return meta_color_choices + get_sword_trail_colors ()
281
281
282
282
283
- def get_bombchu_trail_colors () -> List [str ]:
283
+ def get_bombchu_trail_colors () -> list [str ]:
284
284
return list (bombchu_trail_colors .keys ())
285
285
286
286
287
- def get_bombchu_trail_color_options (outer : bool = False ) -> List [str ]:
287
+ def get_bombchu_trail_color_options (outer : bool = False ) -> list [str ]:
288
288
if outer :
289
289
return ["[Same as Inner]" ] + meta_color_choices + get_bombchu_trail_colors ()
290
290
else :
291
291
return meta_color_choices + get_bombchu_trail_colors ()
292
292
293
293
294
- def get_boomerang_trail_colors () -> List [str ]:
294
+ def get_boomerang_trail_colors () -> list [str ]:
295
295
return list (boomerang_trail_colors .keys ())
296
296
297
297
298
- def get_boomerang_trail_color_options (outer : bool = False ) -> List [str ]:
298
+ def get_boomerang_trail_color_options (outer : bool = False ) -> list [str ]:
299
299
if outer :
300
300
return ["[Same as Inner]" ] + meta_color_choices + get_boomerang_trail_colors ()
301
301
else :
302
302
return meta_color_choices + get_boomerang_trail_colors ()
303
303
304
304
305
- def get_gauntlet_colors () -> List [str ]:
305
+ def get_gauntlet_colors () -> list [str ]:
306
306
return list (gauntlet_colors .keys ())
307
307
308
308
309
- def get_gauntlet_color_options () -> List [str ]:
309
+ def get_gauntlet_color_options () -> list [str ]:
310
310
return meta_color_choices + get_gauntlet_colors ()
311
311
312
312
313
- def get_shield_frame_colors () -> List [str ]:
313
+ def get_shield_frame_colors () -> list [str ]:
314
314
return list (shield_frame_colors .keys ())
315
315
316
316
317
- def get_shield_frame_color_options () -> List [str ]:
317
+ def get_shield_frame_color_options () -> list [str ]:
318
318
return meta_color_choices + get_shield_frame_colors ()
319
319
320
320
321
- def get_heart_colors () -> List [str ]:
321
+ def get_heart_colors () -> list [str ]:
322
322
return list (heart_colors .keys ())
323
323
324
324
325
- def get_heart_color_options () -> List [str ]:
325
+ def get_heart_color_options () -> list [str ]:
326
326
return meta_color_choices + get_heart_colors ()
327
327
328
328
329
- def get_magic_colors () -> List [str ]:
329
+ def get_magic_colors () -> list [str ]:
330
330
return list (magic_colors .keys ())
331
331
332
332
333
- def get_magic_color_options () -> List [str ]:
333
+ def get_magic_color_options () -> list [str ]:
334
334
return meta_color_choices + get_magic_colors ()
335
335
336
336
337
- def get_a_button_colors () -> List [str ]:
337
+ def get_a_button_colors () -> list [str ]:
338
338
return list (a_button_colors .keys ())
339
339
340
340
341
- def get_a_button_color_options () -> List [str ]:
341
+ def get_a_button_color_options () -> list [str ]:
342
342
return meta_color_choices + get_a_button_colors ()
343
343
344
344
345
- def get_b_button_colors () -> List [str ]:
345
+ def get_b_button_colors () -> list [str ]:
346
346
return list (b_button_colors .keys ())
347
347
348
348
349
- def get_b_button_color_options () -> List [str ]:
349
+ def get_b_button_color_options () -> list [str ]:
350
350
return meta_color_choices + get_b_button_colors ()
351
351
352
352
353
- def get_c_button_colors () -> List [str ]:
353
+ def get_c_button_colors () -> list [str ]:
354
354
return list (c_button_colors .keys ())
355
355
356
356
357
- def get_c_button_color_options () -> List [str ]:
357
+ def get_c_button_color_options () -> list [str ]:
358
358
return meta_color_choices + get_c_button_colors ()
359
359
360
360
361
- def get_start_button_colors () -> List [str ]:
361
+ def get_start_button_colors () -> list [str ]:
362
362
return list (start_button_colors .keys ())
363
363
364
364
365
- def get_start_button_color_options () -> List [str ]:
365
+ def get_start_button_color_options () -> list [str ]:
366
366
return meta_color_choices + get_start_button_colors ()
367
367
368
368
369
- def contrast_ratio (color1 : List [int ], color2 : List [int ]) -> float :
369
+ def contrast_ratio (color1 : list [int ], color2 : list [int ]) -> float :
370
370
# Based on accessibility standards (WCAG 2.0)
371
371
lum1 = relative_luminance (color1 )
372
372
lum2 = relative_luminance (color2 )
373
373
return (max (lum1 , lum2 ) + 0.05 ) / (min (lum1 , lum2 ) + 0.05 )
374
374
375
375
376
- def relative_luminance (color : List [int ]) -> float :
376
+ def relative_luminance (color : list [int ]) -> float :
377
377
color_ratios = list (map (lum_color_ratio , color ))
378
378
return color_ratios [0 ] * 0.299 + color_ratios [1 ] * 0.587 + color_ratios [2 ] * 0.114
379
379
@@ -386,11 +386,11 @@ def lum_color_ratio(val: float) -> float:
386
386
return pow ((val + 0.055 ) / 1.055 , 2.4 )
387
387
388
388
389
- def generate_random_color () -> List [int ]:
389
+ def generate_random_color () -> list [int ]:
390
390
return [random .getrandbits (8 ), random .getrandbits (8 ), random .getrandbits (8 )]
391
391
392
392
393
- def hex_to_color (option : str ) -> List [int ]:
393
+ def hex_to_color (option : str ) -> list [int ]:
394
394
if not hasattr (hex_to_color , "regex" ):
395
395
hex_to_color .regex = re .compile (r'^(?:[0-9a-fA-F]{3}){1,2}$' )
396
396
@@ -404,5 +404,5 @@ def hex_to_color(option: str) -> List[int]:
404
404
return list (int (f'{ option [i ]} { option [i ]} ' , 16 ) for i in (0 , 1 , 2 ))
405
405
406
406
407
- def color_to_hex (color : List [int ]) -> str :
407
+ def color_to_hex (color : list [int ]) -> str :
408
408
return '#' + '' .join (['{:02X}' .format (c ) for c in color ])
0 commit comments