-
Notifications
You must be signed in to change notification settings - Fork 0
/
colPalette.py
312 lines (300 loc) · 7.21 KB
/
colPalette.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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# A dictionary of color palettes that allows to map Novation colour scheme to HTML color codes.
# Key is the Midi note number, value is the HTML color code, comment is the color name.
# palette = {
# 0: "616161", # Grey
# 1: "b3b3b3", # Light Grey
# 2: "dddddd", # White
# 3: "ffffff", # Bright White
# 4: "feb3b3", # Pink
# 5: "fd6262", # Bright Pink
# 6: "dd6161", # Red
# 7: "b36060", # Dark Red
# 8: "fff3d6", # Peach
# 9: "fdb462", # Orange
# 10: "db8c63", # Dark Orange
# 11: "b47562", # Brown
# 12: "feeea1", # Yellow
# 13: "fefe60", # Bright Yellow
# 14: "dddd62", # Lime
# 15: "b3b361", # Dark Lime
# 16: "ddfea1", # Green
# 17: "c3fe61", # Bright Green
# 18: "a1dd62", # Light Green
# 19: "81b361", # Dark Green
# 20: "c2feb3", # Turquoise
# 21: "62fd62", # Bright Turquoise
# 22: "62dd61", #
# 23: "61b362", #
# 24: "c3fec2", #
# 25: "61fe8d", #
# 26: "60de75", #
# 27: "61b36b", #
# 28: "c3fecc", #
# 29: "63fdcc", #
# 30: "61dda2", #
# 31: "62b380", #
# 32: "c2fef2", #
# 33: "62fdea", #
# 34: "60ddc3", #
# 35: "61b395", #
# 36: "c2f3fe", #
# 37: "61eefd", #
# 38: "61c7dd", #
# 39: "61a1b3", #
# 40: "c2ddfd", #
# 41: "60c7fd", #
# 42: "60a2dd", #
# 43: "6182b4", #
# 44: "a08cfc", #
# 45: "6161fb", #
# 46: "6161de", #
# 47: "6260b3", #
# 48: "cbb3fe", #
# 49: "a161fc", #
# 50: "8161dd", #
# 51: "7761b3", #
# 52: "fdb3fd", #
# 53: "fd61fd", #
# 54: "dd61de", #
# 55: "b261b1", #
# 56: "fdb3d5", #
# 57: "fe61c2", #
# 58: "dc61a1", #
# 59: "b3618b", #
# 60: "fd7661", #
# 61: "e9b362", #
# 62: "dcc261", #
# 63: "a1a161", #
# 64: "61b361", #
# 65: "61b38c", #
# 66: "618cd6", #
# 67: "6160fd", #
# 68: "62b3b3", #
# 69: "8c61f3", #
# 70: "cdb3c2", #
# 71: "8c7682", #
# 72: "fd6161", #
# 73: "f3fea2", #
# 74: "eefc61", #
# 75: "ccfe61", #
# 76: "76dd61", #
# 77: "61fecc", #
# 78: "61e9fd", #
# 79: "61a1fd", #
# 80: "8c61fc", #
# 81: "cc62fa", #
# 82: "ee8cdd", #
# 83: "a27560", #
# 84: "fda160", #
# 85: "def861", #
# 86: "d5fe8c", #
# 87: "60fe61", #
# 88: "b3fea1", #
# 89: "cdfcd5", #
# 90: "b3fef7", #
# 91: "cce4fe", #
# 92: "a1c3f5", #
# 93: "d5c2f9", #
# 94: "f88dfc", #
# 95: "fc62cc", #
# 96: "fdc261", #
# 97: "f3ee61", #
# 98: "e4fe63", #
# 99: "ddcc61", #
# 100: "b3a162", #
# 101: "61ba76", #
# 102: "76c18d", #
# 103: "8081a1", #
# 104: "818ccb", #
# 105: "ccab81", #
# 106: "dc6161", #
# 107: "f7b4a2", #
# 108: "f8ba77", #
# 109: "fdf38c", #
# 110: "e9faa1", #
# 111: "d5ee78", #
# 112: "8081a1", #
# 113: "f9f9d5", #
# 114: "ddfce4", #
# 115: "e9e9fe", #
# 116: "e4d5fe", #
# 117: "b3b3b3", #
# 118: "d5d5d5", #
# 119: "f8fefe", #
# 120: "e86161", #
# 121: "ab6161", #
# 122: "81f661", #
# 123: "61b361", #
# 124: "f3ee61", #
# 125: "b2a260", #
# 126: "efc162", #
# 127: "c27761" #
# }
palette = [ #Color Palette of Launchpad X
(97,97,97),
(179,179,179),
(221,221,221),
(255,255,255),
(255,179,179),
(255,97,97),
(221,97,97),
(179,97,97),
(255,243,213),
(255,179,97),
(221,140,97),
(179,118,97),
(255,238,161),
(255,255,97),
(221,221,97),
(179,179,97),
(221,255,161),
(194,255,97),
(161,221,97),
(129,179,97),
(194,255,179),
(97,255,97),
(97,221,97),
(97,179,97),
(194,255,194),
(97,255,140),
(97,221,118),
(97,179,107),
(194,255,204),
(97,255,204),
(97,221,161),
(97,179,129),
(194,255,243),
(97,255,233),
(97,221,194),
(97,179,150),
(194,243,255),
(97,238,255),
(97,199,221),
(97,161,179),
(194,221,255),
(97,199,255),
(97,161,221),
(97,129,179),
(161,140,255),
(97,97,255),
(97,97,221),
(97,97,179),
(204,179,255),
(161,97,255),
(129,97,221),
(118,97,179),
(255,179,255),
(255,97,255),
(221,97,221),
(179,97,179),
(255,179,213),
(255,97,194),
(221,97,161),
(179,97,140),
(255,118,97),
(233,179,97),
(221,194,97),
(161,161,97),
(97,179,97),
(97,179,140),
(97,140,213),
(97,97,255),
(97,179,179),
(140,97,243),
(204,179,194),
(140,118,129),
(255,97,97),
(243,255,161),
(238,252,97),
(204,255,97),
(118,221,97),
(97,255,204),
(97,233,255),
(97,161,255),
(140,97,255),
(204,97,252),
(238,140,221),
(161,118,97),
(255,161,97),
(221,249,97),
(213,255,140),
(97,255,97),
(179,255,161),
(204,252,213),
(179,255,246),
(204,228,255),
(161,194,246),
(213,194,249),
(249,140,255),
(255,97,204),
(255,194,97),
(243,238,97),
(228,255,97),
(221,204,97),
(179,161,97),
(97,186,118),
(118,194,140),
(129,129,161),
(129,140,204),
(204,170,129),
(221,97,97),
(249,179,161),
(249,186,118),
(255,243,140),
(233,249,161),
(213,238,118),
(255,255,255),
(249,249,213),
(221,252,228),
(233,233,255),
(228,213,255),
(179,179,179),
(213,213,213),
(249,255,255),
(233,97,97),
(170,97,97),
(129,246,97),
(97,179,97),
(243,238,97),
(179,161,97),
(238,194,97),
(194,118,97),
]
def convertColor(color) -> int: #Convert FL Studio provided color value to color in Launchpad/Launchkey Color Palette
if color == 10462118:
return 0
if color > 0:
RGBHex = hex(color)
else:
RGBHex = hex(16777216 + color)
RGBSplit = [RGBHex[i:i+2] for i in range(0, len(RGBHex), 2)]
RGBInt = [int, int, int]
for i in range(1,4):
if (int(RGBSplit[i], 16) * 1.5) > 254:
RGBInt[i-1] = 255
else:
RGBInt[i-1] = int(RGBSplit[i], 16) * 1.5
return getPaletteColorFromRGB([RGBInt[0], RGBInt[1], RGBInt[2]])
def getPaletteColorFromRGB(input: (int, int, int)) -> int: #Gets closest Palette Color to RGB # type: ignore
best_palette_match = 0
best_palette_match_distance = (0.3 * (input[0] - palette[0][0])**2) + (0.6 * (input[1] - palette[0][1])**2) + (0.1 * (input[2] - palette[0][2])**2)
# we already checked [0]
for i in range(1, len(palette)):
distance = (0.3 * (input[0] - palette[i][0])**2) + (0.6 * (input[1] - palette[i][1])**2) + (0.1 * (input[2] - palette[i][2])**2)
if distance < best_palette_match_distance:
best_palette_match = i
best_palette_match_distance = distance
return best_palette_match
from mixer import getTrackColor
from channels import getChannelColor
from playlist import getLiveBlockColor
def mixerColorNumber(track: int) -> int: # Get Novation color number based on mixer track color, this number can be passed to midiOutMsg to color the pads
return convertColor(getTrackColor(track))
def channelColorNumber(channel: int) -> int: # Get Novation color number based on channel color, this number can be passed to midiOutMsg to color the pads
#return convertColor(getChannelColor(channel))
if convertColor(getChannelColor(channel)) == 0:
return 71
else:
return convertColor(getChannelColor(channel))
def perfColorNumber(track: int, clip: int) -> int: # Get Novation color number based on playlist track color, this number can be passed to midiOutMsg to color the pads
return convertColor(getLiveBlockColor(track, clip))