-
Notifications
You must be signed in to change notification settings - Fork 135
/
pixastic.worker.js
47 lines (39 loc) · 1.12 KB
/
pixastic.worker.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
Pixastic.Worker = function() {
var me = this;
function processMessage(data) {
var queue = data.queue,
inData = data.inData,
outData = data.outData,
width = data.width,
height = data.height,
tmpData;
for (var i=0;i<queue.length;i++) {
var e = queue[i].effect,
options = queue[i].options;
if (i > 0) {
tmpData = inData;
inData = outData;
outData = tmpData;
}
Pixastic.Effects[e](inData.data, outData.data, width, height, options);
me.onmessage({
data : {
event : "progress",
data : (i+1) / queue.length
}
});
}
me.onmessage({
data : {
event : "done",
data : outData
}
});
}
this.postMessage = function(data) {
setTimeout(function() {
processMessage(data)
}, 0);
}
this.onmessage = function() {};
}