forked from cameramanben/LUTCalc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwk-fc.js
335 lines (334 loc) · 11.7 KB
/
twk-fc.js
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
/* twk-fc.js
* False Colour customisation object for the LUTCalc Web App.
* 10th April 2015
*
* LUTCalc generates 1D and 3D Lookup Tables (LUTs) for video cameras that shoot log gammas,
* principally the Sony CineAlta line.
*
* By Ben Turley, http://turley.tv
* First License: GPLv2
* Github: https://github.com/cameramanben/LUTCalc
*/
function TWKFC(tweaksBox, inputs, messages) {
this.tweaksBox = tweaksBox;
this.inputs = inputs;
this.messages = messages;
this.io();
this.ui();
}
TWKFC.prototype.io = function() {
// Tweak Checkbox
this.tweakCheck = document.createElement('input');
this.tweakCheck.setAttribute('type','checkbox');
this.tweakCheck.className = 'twk-checkbox';
this.tweakCheck.checked = false;
// Tweak - Specific Inputs
// Purple - Black Clip
this.purpleCheck = document.createElement('input');
this.purpleCheck.setAttribute('type','checkbox');
this.purpleCheck.className = 'twk-checkbox';
this.purpleCheck.checked = true;
// Blue - Just Above Black Clip
this.blueCheck = document.createElement('input');
this.blueCheck.setAttribute('type','checkbox');
this.blueCheck.className = 'twk-checkbox';
this.blueCheck.checked = true;
this.blueInput = document.createElement('input');
this.blueInput.setAttribute('type','number');
this.blueInput.setAttribute('step','any');
this.blueInput.className = 'stopinput';
this.blueInput.value = '6.1';
// Green - 18% Gray
this.greenCheck = document.createElement('input');
this.greenCheck.setAttribute('type','checkbox');
this.greenCheck.className = 'twk-checkbox';
this.greenCheck.checked = true;
// Pink - One Stop Over 18% Gray
this.pinkCheck = document.createElement('input');
this.pinkCheck.setAttribute('type','checkbox');
this.pinkCheck.className = 'twk-checkbox';
this.pinkCheck.checked = true;
// Orange - 90% White
this.orangeCheck = document.createElement('input');
this.orangeCheck.setAttribute('type','checkbox');
this.orangeCheck.className = 'twk-checkbox';
this.orangeCheck.checked = false;
// Yellow - Just Below White Clip
this.yellowCheck = document.createElement('input');
this.yellowCheck.setAttribute('type','checkbox');
this.yellowCheck.className = 'twk-checkbox';
this.yellowCheck.checked = true;
this.yellowInput = document.createElement('input');
this.yellowInput.setAttribute('type','number');
this.yellowInput.setAttribute('step','any');
this.yellowInput.className = 'stopinput';
this.yellowInput.value = '0.5';
// Red - White Clip
this.redCheck = document.createElement('input');
this.redCheck.setAttribute('type','checkbox');
this.redCheck.className = 'twk-checkbox';
this.redCheck.checked = true;
this.redInput = document.createElement('input');
this.redInput.setAttribute('type','number');
this.redInput.setAttribute('step','any');
this.redInput.className = 'stopinput';
this.redInput.value = '6';
};
TWKFC.prototype.ui = function() {
// General Tweak Holder (Including Checkbox)
this.holder = document.createElement('div');
this.holder.className = 'tweakholder-hide';
this.tweaksBox.appendChild(this.holder);
this.holder.appendChild(document.createElement('label').appendChild(document.createTextNode('False Colour')));
this.holder.appendChild(this.tweakCheck);
// Tweak Box - Inputs Which Appear When the Tweak Checkbox Is Ticked
this.box = document.createElement('div');
this.box.className = 'tweak-hide';
// Tweak - Specific UI Elements
var purpleBox = document.createElement('div');
purpleBox.className = 'twk-sub-box';
purpleBox.appendChild(document.createElement('label').appendChild(document.createTextNode('Purple - Black Clip')));
purpleBox.appendChild(this.purpleCheck);
this.box.appendChild(purpleBox);
var blueBox = document.createElement('div');
blueBox.className = 'twk-sub-box';
blueBox.appendChild(document.createElement('label').appendChild(document.createTextNode('Blue - Just Above Black Clip')));
blueBox.appendChild(this.blueCheck);
blueBox.appendChild(document.createElement('br'));
blueBox.appendChild(this.blueInput);
blueBox.appendChild(document.createElement('label').appendChild(document.createTextNode('Stops Below 18% Gray')));
this.box.appendChild(blueBox);
var greenBox = document.createElement('div');
greenBox.className = 'twk-sub-box';
greenBox.appendChild(document.createElement('label').appendChild(document.createTextNode('Green - 18% Mid Gray')));
greenBox.appendChild(this.greenCheck);
this.box.appendChild(greenBox);
var pinkBox = document.createElement('div');
pinkBox.className = 'twk-sub-box';
pinkBox.appendChild(document.createElement('label').appendChild(document.createTextNode('Pink - One Stop Over 18% Mid Gray')));
pinkBox.appendChild(this.pinkCheck);
this.box.appendChild(pinkBox);
var orangeBox = document.createElement('div');
orangeBox.className = 'twk-sub-box';
orangeBox.appendChild(document.createElement('label').appendChild(document.createTextNode('Orange - 90% White')));
orangeBox.appendChild(this.orangeCheck);
this.box.appendChild(orangeBox);
var yellowBox = document.createElement('div');
yellowBox.className = 'twk-sub-box';
yellowBox.appendChild(document.createElement('label').appendChild(document.createTextNode('Yellow - Just Below White Clip')));
yellowBox.appendChild(this.yellowCheck);
yellowBox.appendChild(document.createElement('br'));
yellowBox.appendChild(this.yellowInput);
yellowBox.appendChild(document.createElement('label').appendChild(document.createTextNode('Stops Below White Clip')));
this.box.appendChild(yellowBox);
var redBox = document.createElement('div');
redBox.className = 'twk-sub-box';
redBox.appendChild(document.createElement('label').appendChild(document.createTextNode('Red - White Clip')));
redBox.appendChild(this.redCheck);
redBox.appendChild(document.createElement('br'));
redBox.appendChild(this.redInput);
redBox.appendChild(document.createElement('label').appendChild(document.createTextNode('Stops Above 18% Mid Gray')));
this.box.appendChild(redBox);
// Build Box Hierarchy
this.holder.appendChild(this.box);
};
TWKFC.prototype.toggleTweaks = function() {
// If The Overall Checkbox Is Ticked
if (this.inputs.tweaks.checked && this.inputs.d[1].checked) { // This checks for 'Customisations' to be checked and LUT type set to '3D' (the d[1] item)
if (this.inputs.outGamma.options[this.inputs.outGamma.selectedIndex].lastChild.nodeValue !== 'Null') {
this.holder.className = 'tweakholder';
} else {
this.holder.className = 'tweakholder-hide';
this.tweakCheck.checked = false;
}
} else {
this.holder.className = 'tweakholder-hide';
this.tweakCheck.checked = false;
}
this.toggleTweak();
};
TWKFC.prototype.toggleTweak = function() {
if (this.tweakCheck.checked) {
this.box.className = 'tweak';
} else {
this.box.className = 'tweak-hide';
}
};
TWKFC.prototype.getTFParams = function(params) {
// No Relevant Parameters For This Tweak
};
TWKFC.prototype.getCSParams = function(params) {
var out = {};
var tweaks = this.inputs.tweaks.checked;
var tweak = this.tweakCheck.checked;
if (tweaks && tweak) {
out.doFC = true;
out.fcs = [
this.purpleCheck.checked,
this.blueCheck.checked,
this.greenCheck.checked,
this.pinkCheck.checked,
this.orangeCheck.checked,
this.yellowCheck.checked,
this.redCheck.checked
];
} else {
out.doFC = false;
}
out.blue = parseFloat(this.blueInput.value);
out.yellow = parseFloat(this.yellowInput.value);
out.red = parseFloat(this.redInput.value);
params.twkFC = out;
};
TWKFC.prototype.setParams = function(params) {
if (typeof params.twkBLANK !== 'undefined') {
var p = params.twkBLANK;
this.toggleTweaks();
}
// Any changes to UI inputs coming from the gamma and gamut workers should go here
};
TWKFC.prototype.getSettings = function(data) {
data.falseColour = {
doFC: this.tweakCheck.checked,
doPurple: this.purpleCheck.checked,
doBlue: this.blueCheck.checked,
doGreen: this.greenCheck.checked,
doPink: this.pinkCheck.checked,
doOrange: this.orangeCheck.checked,
doYellow: this.yellowCheck.checked,
doRed: this.redCheck.checked,
blue: parseFloat(this.blueInput.value),
yellow: parseFloat(this.yellowInput.value),
red: parseFloat(this.redInput.value)
};
};
TWKFC.prototype.setSettings = function(settings) {
if (typeof settings.falseColour !== 'undefined') {
var data = settings.falseColour;
if (typeof data.doFC === 'boolean') {
this.tweakCheck.checked = data.doFC;
this.toggleTweak();
}
if (typeof data.doPurple === 'boolean') {
this.purpleCheck.checked = data.doPurple;
}
if (typeof data.doBlue === 'boolean') {
this.blueCheck.checked = data.doBlue;
}
if (typeof data.doGreen === 'boolean') {
this.greenCheck.checked = data.doGreen;
}
if (typeof data.doPink === 'boolean') {
this.pinkCheck.checked = data.doPink;
}
if (typeof data.doOrange === 'boolean') {
this.orangeCheck.checked = data.doOrange;
}
if (typeof data.doYellow === 'boolean') {
this.yellowCheck.checked = data.doYellow;
}
if (typeof data.doRed === 'boolean') {
this.redCheck.checked = data.doRed;
}
if (typeof data.blue === 'number') {
this.blueInput.value = data.blue.toString();
}
if (typeof data.yellow === 'number') {
this.yellowInput.value = data.yellow.toString();
}
if (typeof data.red === 'number') {
this.redInput.value = data.red.toString();
}
}
};
TWKFC.prototype.getInfo = function(info) {
var tweaks = this.inputs.tweaks.checked;
var tweak = this.tweakCheck.checked;
if (tweaks && tweak) {
info.doFC = true;
} else {
info.doFC = false;
}
};
TWKFC.prototype.isCustomGamma = function() {
return false;
};
TWKFC.prototype.isCustomGamut = function() {
var tweaks = this.inputs.tweaks.checked;
var tweak = this.tweakCheck.checked;
if (tweaks && tweak) {
return true;
} else {
return false;
}
};
TWKFC.prototype.events = function() {
this.tweakCheck.onclick = function(here){ return function(){
here.toggleTweak();
here.messages.gtSetParams();
};}(this);
// Event responses for input changes or click should go here
this.purpleCheck.onclick = function(here){ return function(){
here.messages.gtSetParams();
};}(this);
this.blueCheck.onclick = function(here){ return function(){
here.messages.gtSetParams();
};}(this);
this.greenCheck.onclick = function(here){ return function(){
here.messages.gtSetParams();
};}(this);
this.pinkCheck.onclick = function(here){ return function(){
here.messages.gtSetParams();
};}(this);
this.orangeCheck.onclick = function(here){ return function(){
here.messages.gtSetParams();
};}(this);
this.yellowCheck.onclick = function(here){ return function(){
here.messages.gtSetParams();
};}(this);
this.redCheck.onclick = function(here){ return function(){
here.messages.gtSetParams();
};}(this);
this.blueInput.onchange = function(here){ return function(){
here.testBlue();
here.messages.gtSetParams();
};}(this);
this.yellowInput.onchange = function(here){ return function(){
here.testYellow();
here.messages.gtSetParams();
};}(this);
this.redInput.onchange = function(here){ return function(){
here.testRed();
here.messages.gtSetParams();
};}(this);
};
// Tweak-Specific Code
TWKFC.prototype.testBlue = function() {
if (!isNaN(parseFloat(this.blueInput.value)) && isFinite(this.blueInput.value)) {
if (parseFloat(this.blueInput.value)<1) {
this.blueInput.value = '1';
}
} else {
this.blueInput.value = '6.1';
}
};
TWKFC.prototype.testYellow = function() {
if (!isNaN(parseFloat(this.yellowInput.value)) && isFinite(this.yellowInput.value)) {
if (parseFloat(this.yellowInput.value)<0.0001) {
this.yellowInput.value = '0.0001';
} else if (parseFloat(this.yellowInput.value)>3) {
this.yellowInput.value = '3';
}
} else {
this.yellowInput.value = '0.5';
}
};
TWKFC.prototype.testRed = function() {
if (!isNaN(parseFloat(this.redInput.value)) && isFinite(this.redInput.value)) {
if (parseFloat(this.redInput.value)<3.5) {
this.redInput.value = '3.5';
}
} else {
this.redInput.value = '6';
}
};