Code cleanup, re-organizing and tidying (#226)

* initial cleanup

* build

* additions and build
This commit is contained in:
Jeffrey Warren
2018-04-29 12:16:11 -04:00
committed by GitHub
parent 711ae62ee3
commit 2abf0fae09
25 changed files with 575 additions and 540 deletions

View File

@@ -0,0 +1,58 @@
/*
* Display only one color channel
*/
module.exports = function Channel(options,UI) {
options = options || {};
options.channel = options.channel || "green";
// Tell UI that a step has been set up
UI.onSetup(options.step);
var output;
function draw(input,callback,progressObj) {
progressObj.stop(true);
progressObj.overrideFlag = true;
// Tell UI that a step is being drawn
UI.onDraw(options.step);
var step = this;
function changePixel(r, g, b, a) {
if (options.channel == "red") return [r, 0, 0, a];
if (options.channel == "green") return [0, g, 0, a];
if (options.channel == "blue") return [0, 0, b, a];
}
function output(image,datauri,mimetype){
// This output is accesible by Image Sequencer
step.output = {src:datauri,format:mimetype};
// This output is accessible by UI
options.step.output = datauri;
// Tell UI that step ahs been drawn
UI.onComplete(options.step);
}
return require('../_nomodule/PixelManipulation.js')(input, {
output: output,
changePixel: changePixel,
format: input.format,
image: options.image,
inBrowser: options.inBrowser,
callback: callback
});
}
return {
options: options,
//setup: setup, // optional
draw: draw,
output: output,
UI: UI
}
}