mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
fixed palette import bug
This commit is contained in:
parent
258d13371d
commit
b5465ca066
17
src/js/utils/WorkerUtils.js
Normal file
17
src/js/utils/WorkerUtils.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
(function () {
|
||||||
|
var ns = $.namespace('pskl.utils');
|
||||||
|
|
||||||
|
var workers = {};
|
||||||
|
|
||||||
|
ns.WorkerUtils = {
|
||||||
|
createWorker : function (worker, workerId) {
|
||||||
|
if (!workers[workerId]) {
|
||||||
|
var typedArray = [(worker+"").replace(/function \(\)\s?\{/,"").replace(/\}[^}]*$/, "")];
|
||||||
|
var blob = new Blob(typedArray, {type: "application/javascript"}); // pass a useful mime type here
|
||||||
|
workers[workerId] = window.URL.createObjectURL(blob);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Worker(workers[workerId]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
@ -24,8 +24,13 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var rgbToHex = function(r, g, b) {
|
var rgbToHex = function (r, g, b) {
|
||||||
return '#' + ((r << 16) | (g << 8) | b).toString(16);
|
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
|
||||||
|
};
|
||||||
|
|
||||||
|
var componentToHex = function (c) {
|
||||||
|
var hex = c.toString(16);
|
||||||
|
return hex.length == 1 ? "0" + hex : hex;
|
||||||
};
|
};
|
||||||
|
|
||||||
var imageDataToGrid = function (imageData, width, height, transparent) {
|
var imageDataToGrid = function (imageData, width, height, transparent) {
|
||||||
@ -96,7 +101,7 @@
|
|||||||
this.onError = onError;
|
this.onError = onError;
|
||||||
|
|
||||||
// var worker = pskl.utils.WorkerUtils.addPartialWorker(imageProcessorWorker, 'step-counter');
|
// var worker = pskl.utils.WorkerUtils.addPartialWorker(imageProcessorWorker, 'step-counter');
|
||||||
this.worker = pskl.utils.WorkerUtils.createWorker(worker, 'image-colors-processor');
|
this.worker = pskl.utils.WorkerUtils.createWorker(imageProcessorWorker, 'image-colors-processor');
|
||||||
this.worker.onmessage = this.onWorkerMessage.bind(this);
|
this.worker.onmessage = this.onWorkerMessage.bind(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user