This repository has been archived on 2024-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
epubreader/public/pixastic/pixastic.worker.js
2023-06-18 01:47:01 +02:00

48 lines
1.1 KiB
JavaScript

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() {};
}