mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-17 13:50:04 +01:00
* 1.7.0 * fix the api Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * fixes #266 Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * finally got this to work! Phew :D Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * remove extra log Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * getStepAPI in insertStep Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * add getPreviousStep API Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * more api Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * changes and refactor Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * now using this.getStep and related functions Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * add getNextStep Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * minor refactor Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * fix Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * update getIndex Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
/*
|
|
* Invert the image
|
|
*/
|
|
module.exports = function Invert(options, UI) {
|
|
|
|
options = options || {};
|
|
|
|
// Tell UI that a step has been set up.
|
|
UI.onSetup(options.step);
|
|
var output;
|
|
|
|
// The function which is called on every draw.
|
|
function draw(input, callback, progressObj) {
|
|
|
|
console.log(this.getIndex());
|
|
console.log(this.getPreviousStep().options.name);
|
|
console.log(this.getStep(0).options.name);
|
|
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) {
|
|
return [255 - r, 255 - g, 255 - b, a];
|
|
}
|
|
|
|
function output(image, datauri, mimetype) {
|
|
|
|
// This output is accessible by Image Sequencer
|
|
step.output = { src: datauri, format: mimetype };
|
|
|
|
// This output is accessible by UI
|
|
options.step.output = datauri;
|
|
|
|
// Tell UI that step has 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,
|
|
draw: draw,
|
|
output: output,
|
|
UI: UI
|
|
}
|
|
}
|