-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcct.js
More file actions
46 lines (44 loc) · 1.4 KB
/
cct.js
File metadata and controls
46 lines (44 loc) · 1.4 KB
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
function showX(xPosition) {
$("#words").text("You clicked on "+xPosition);
}
var CCT = {
Settings: {
container: "#cct-canvas",
source: convertCCT,
width: convertCCT.length*2,
height: 40
},
init: function() {
$(CCT.Settings.container).drawRect({
layer: true,
fillStyle: "#000000",
x: (CCT.Settings.width / 2 +1), y: (CCT.Settings.height / 2),
width: CCT.Settings.width,
height: CCT.Settings.height
});
for(var i=0; i<200; i++) {
var tempSource = CCT.Settings.source[i];
var r = tempSource.r;
var g = tempSource.g;
var b = tempSource.b;
var t = tempSource.t;
var d = tempSource.d;
(function(r, g, b, t, d) {
$(CCT.Settings.container).drawRect({
layer: true,
fillStyle: tempSource.s,
x: 2*i+5, y: (CCT.Settings.height /2),
width: 2,
height: CCT.Settings.height-10,
click: function(layer) {
str = layer.eventX+", R: "+r+" G: "+g+" B: "+b+", related temperature is "+t+" K "+d+" deg.";
showX(str);
}
});
})(r, g, b, t, d)
}
}
}
$(document).ready(function() {
CCT.init();
});