-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchar_map.py
81 lines (74 loc) · 2.46 KB
/
char_map.py
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
"""Module which make pixels arrays from text for heatmap"""
char_map = {
' ': ((18, 18), (19, 34)),
'\t': ((8, 1), (9, 4)),
'`~ёЁ': ((4, 1), (5, 2)),
'1!': ((4, 5), (5, 6)),
'2@2"': ((4, 9), (5, 10)),
'3#3№': ((4, 13), (5, 14)),
'4$4;': ((4, 17), (5, 18)),
'5%': ((4, 20), (5, 21)),
'6^6:': ((4, 24), (5, 25)),
'7&7?': ((4, 28), (5, 29)),
'8*': ((4, 32), (5, 33)),
'9(': ((4, 36), (5, 37)),
'0)': ((4, 40), (5, 41)),
'-_': ((4, 44), (5, 45)),
'=+': ((4, 48), (5, 49)),
'qQйЙ': ((8, 7), (9, 8)),
'wWцЦ': ((8, 11), (9, 12)),
'eEуУ': ((8, 15), (9, 16)),
'rRкК': ((8, 19), (9, 20)),
'tTеЕ': ((8, 22), (9, 23)),
'yYнН': ((8, 26), (9, 27)),
'uUгГ': ((8, 30), (9, 31)),
'iIшШ': ((8, 34), (9, 35)),
'oOщЩ': ((8, 38), (9, 39)),
'pPзЗ': ((8, 42), (9, 43)),
'[{хХ': ((8, 46), (9, 47)),
']}ъЪ': ((8, 50), (9, 51)),
'\\|\\/': ((8, 54), (9, 55)),
'aAфФ': ((11, 8), (12, 9)),
'sSыЫ': ((11, 12), (12, 13)),
'dDвВ': ((11, 16), (12, 17)),
'fFаА': ((11, 20), (12, 21)),
'gGпП': ((11, 23), (12, 24)),
'hHрР': ((11, 27), (12, 28)),
'jJоО': ((11, 31), (12, 32)),
'kKлЛ': ((11, 35), (12, 36)),
'lLдД': ((11, 39), (12, 40)),
';:жЖ': ((11, 43), (12, 44)),
'zZяЯ': ((15, 10), (16, 11)),
'xXчЧ': ((15, 14), (16, 15)),
'cCсС': ((15, 18), (16, 19)),
'vVмМ': ((15, 22), (16, 23)),
'bBиИ': ((15, 25), (16, 26)),
'nNтТ': ((15, 29), (16, 30)),
'mMьЬ': ((15, 33), (16, 34)),
',<бБ': ((15, 37), (16, 38)),
'.>юЮ': ((15, 41), (16, 42)),
'/?.,': ((15, 45), (16, 46)),
'\n': ((11, 51), (12, 55)),
'\'"эЭ': ((11, 47), (12, 48))
}
keys = char_map.keys()
left_shift = [
(15, 1), (15, 2), (15, 3), (15, 4), (15, 5), (15, 6), (15, 7),
(16, 1), (16, 2), (16, 3), (16, 4), (16, 5), (16, 6), (16, 7)
]
def get_all_pixels(coordinates):
"""Get all pixel coordinates, given the top left and bottom right."""
pixels = []
x1, y1 = coordinates[0]
x2, y2 = coordinates[1]
for ix in range(x1, x2 + 1):
for iy in range(y1, y2 + 1):
pixels.append((ix, iy))
return pixels
def get_coords(char):
"""Get the coordinate of a key from the key map."""
for key in (item for item in keys if char in item):
pixels = get_all_pixels(char_map[key])
if key.index(char) in (1, 3):
pixels += left_shift
return pixels