mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-11 19:00:00 +01:00
43 lines
1000 B
JavaScript
43 lines
1000 B
JavaScript
module.exports = function Colormap(options, UI) {
|
|
|
|
var output;
|
|
|
|
// This function is called on every draw.
|
|
function draw(input, callback, progressObj) {
|
|
|
|
progressObj.stop(true);
|
|
progressObj.overrideFlag = true;
|
|
|
|
var step = this;
|
|
|
|
function changePixel(r, g, b, a) {
|
|
var combined = (r + g + b) / 3.000;
|
|
var res = require('./Colormap')(combined, options);
|
|
return [res[0], res[1], res[2], 255];
|
|
}
|
|
|
|
function output(image, datauri, mimetype, wasmSuccess) {
|
|
step.output = { src: datauri, format: mimetype, wasmSuccess, useWasm: options.useWasm };
|
|
}
|
|
|
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
|
output: output,
|
|
ui: options.step.ui,
|
|
changePixel: changePixel,
|
|
format: input.format,
|
|
image: options.image,
|
|
inBrowser: options.inBrowser,
|
|
callback: callback,
|
|
useWasm:options.useWasm
|
|
});
|
|
|
|
}
|
|
|
|
return {
|
|
options: options,
|
|
draw: draw,
|
|
output: output,
|
|
UI: UI
|
|
};
|
|
};
|