Minimize mod req (#289)

* remove trailing spaces from Run.js

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* minimize module requirements demonstrated with invert fixes #122

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* refactored modules

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* update docs

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* remove all trailing spaces from all files

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* fixing crop module

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* fix

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>

* update contributing.md

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
This commit is contained in:
Varun Gupta
2018-06-16 01:14:18 +05:30
committed by Jeffrey Warren
parent 5132612dc2
commit 8d6b82d988
27 changed files with 264 additions and 567 deletions

View File

@@ -35,23 +35,18 @@ Any module must follow this basic format:
```js ```js
module.exports = function ModuleName(options,UI) { module.exports = function ModuleName(options,UI) {
options = options || {};
UI.onSetup(options.step);
var output; var output;
// Module requirements have bbeen simplified in version 3, see https://github.com/publiclab/image-sequencer/blob/master/CONTRIBUTING.md#contributing-modules
function draw(input,callback) { function draw(input,callback) {
UI.onDraw(options.step); // tell the UI to "draw"
var output = function(input){ var output = function(input){
/* do something with the input */ /* do something with the input */
return input; return input;
} }
this.output = output(input); // run the output and assign it to this.output this.output = output(input); // run the output and assign it to this.output
options.step.output = output.src;
callback(); callback();
UI.onComplete(options.step); // tell UI we are done
} }
return { return {
@@ -171,32 +166,25 @@ The default "loading spinner" can be optionally overriden with a custom progress
```js ```js
module.exports = function ModuleName(options,UI) { module.exports = function ModuleName(options,UI) {
options = options || {};
UI.onSetup(options.step);
var output; var output;
function draw(input,callback,progressObj) { function draw(input,callback,progressObj) {
/* If you wish to supply your own progress bar you need to override progressObj */ /* If you wish to supply your own progress bar you need to override progressObj */
progressObj.stop() // Stop the current progress spinner progressObj.stop() // Stop the current progress spinner
progressObj.overrideFlag = true; // Tell image sequencer that you will supply your own progressBar progressObj.overrideFlag = true; // Tell image sequencer that you will supply your own progressBar
/* Override the object and give your own progress Bar */ /* Override the object and give your own progress Bar */
progressObj = /* Your own progress Object */ progressObj = /* Your own progress Object */
UI.onDraw(options.step);
var output = function(input){ var output = function(input){
/* do something with the input */ /* do something with the input */
return input; return input;
}; };
this.output = output(); this.output = output();
options.step.output = output.src;
callback(); callback();
UI.onComplete(options.step);
} }
return { return {

View File

@@ -47260,7 +47260,7 @@ arguments[4][38][0].apply(exports,arguments)
},{"dup":38}],134:[function(require,module,exports){ },{"dup":38}],134:[function(require,module,exports){
arguments[4][39][0].apply(exports,arguments) arguments[4][39][0].apply(exports,arguments)
},{"./support/isBuffer":133,"_process":97,"dup":39,"inherits":56}],135:[function(require,module,exports){ },{"./support/isBuffer":133,"_process":97,"dup":39,"inherits":56}],135:[function(require,module,exports){
// add steps to the sequencer // add steps to the sequencer
// TODO: reduce redundancy with InsertStep; this should be a specific usage of InsertStep at the final position // TODO: reduce redundancy with InsertStep; this should be a specific usage of InsertStep at the final position
function AddStep(_sequencer, image, name, o) { function AddStep(_sequencer, image, name, o) {
@@ -47287,7 +47287,12 @@ function AddStep(_sequencer, image, name, o) {
options: o options: o
}; };
var UI = _sequencer.events; var UI = _sequencer.events;
// Tell UI that a step has been set up.
o = o || {};
UI.onSetup(o.step);
var module = _sequencer.modules[name][0](o, UI); var module = _sequencer.modules[name][0](o, UI);
_sequencer.images[image].steps.push(module); _sequencer.images[image].steps.push(module);
return true; return true;
@@ -47951,7 +47956,7 @@ module.exports = {
},{"./modules/Average/Module":143,"./modules/Average/info":144,"./modules/Blend/Module":145,"./modules/Blend/info":146,"./modules/Blur/Module":148,"./modules/Blur/info":149,"./modules/Brightness/Module":150,"./modules/Brightness/info":151,"./modules/Channel/Module":152,"./modules/Channel/info":153,"./modules/Colormap/Module":155,"./modules/Colormap/info":156,"./modules/Crop/Module":158,"./modules/Crop/info":160,"./modules/DecodeQr/Module":161,"./modules/DecodeQr/info":162,"./modules/Dynamic/Module":163,"./modules/Dynamic/info":164,"./modules/EdgeDetect/Module":166,"./modules/EdgeDetect/info":167,"./modules/FisheyeGl/Module":168,"./modules/FisheyeGl/info":169,"./modules/ImportImage/Module":170,"./modules/ImportImage/info":172,"./modules/Invert/Module":173,"./modules/Invert/info":174,"./modules/Ndvi/Module":175,"./modules/Ndvi/info":176,"./modules/Saturation/Module":177,"./modules/Saturation/info":178}],141:[function(require,module,exports){ },{"./modules/Average/Module":143,"./modules/Average/info":144,"./modules/Blend/Module":145,"./modules/Blend/info":146,"./modules/Blur/Module":148,"./modules/Blur/info":149,"./modules/Brightness/Module":150,"./modules/Brightness/info":151,"./modules/Channel/Module":152,"./modules/Channel/info":153,"./modules/Colormap/Module":155,"./modules/Colormap/info":156,"./modules/Crop/Module":158,"./modules/Crop/info":160,"./modules/DecodeQr/Module":161,"./modules/DecodeQr/info":162,"./modules/Dynamic/Module":163,"./modules/Dynamic/info":164,"./modules/EdgeDetect/Module":166,"./modules/EdgeDetect/info":167,"./modules/FisheyeGl/Module":168,"./modules/FisheyeGl/info":169,"./modules/ImportImage/Module":170,"./modules/ImportImage/info":172,"./modules/Invert/Module":173,"./modules/Invert/info":174,"./modules/Ndvi/Module":175,"./modules/Ndvi/info":176,"./modules/Saturation/Module":177,"./modules/Saturation/info":178}],141:[function(require,module,exports){
// Uses a given image as input and replaces it with the output. // Uses a given image as input and replaces it with the output.
// Works only in the browser. // Works only in the browser.
function ReplaceImage(ref,selector,steps,options) { function ReplaceImage(ref,selector,steps,options) {
if(!ref.options.inBrowser) return false; // This isn't for Node.js if(!ref.options.inBrowser) return false; // This isn't for Node.js
var tempSequencer = ImageSequencer({ui: false}); var tempSequencer = ImageSequencer({ui: false});
@@ -48015,7 +48020,7 @@ const getStepUtils = require('./util/getStep.js');
function Run(ref, json_q, callback,ind, progressObj) { function Run(ref, json_q, callback,ind, progressObj) {
if (!progressObj) progressObj = { stop: function () { } }; if (!progressObj) progressObj = { stop: function () { } };
function drawStep(drawarray, pos) { function drawStep(drawarray, pos) {
if (pos == drawarray.length && drawarray[pos - 1] !== undefined) { if (pos == drawarray.length && drawarray[pos - 1] !== undefined) {
var image = drawarray[pos - 1].image; var image = drawarray[pos - 1].image;
@@ -48026,13 +48031,13 @@ function Run(ref, json_q, callback,ind, progressObj) {
return true; return true;
} }
} }
// so we don't run on the loadImage module: // so we don't run on the loadImage module:
if (drawarray[pos] !== undefined) { if (drawarray[pos] !== undefined) {
var image = drawarray[pos].image; var image = drawarray[pos].image;
var i = drawarray[pos].i; var i = drawarray[pos].i;
var input = ref.images[image].steps[i - 1].output; var input = ref.images[image].steps[i - 1].output;
ref.images[image].steps[i].getStep = function getStep(offset) { ref.images[image].steps[i].getStep = function getStep(offset) {
if(i + offset >= ref.images[image].steps.length) return {options:{name:undefined}}; if(i + offset >= ref.images[image].steps.length) return {options:{name:undefined}};
else return ref.images[image].steps.slice(i + offset)[0]; else return ref.images[image].steps.slice(i + offset)[0];
@@ -48040,23 +48045,33 @@ function Run(ref, json_q, callback,ind, progressObj) {
ref.images[image].steps[i].getIndex = function getIndex(){ ref.images[image].steps[i].getIndex = function getIndex(){
return i; return i;
} }
for (var util in getStepUtils) { for (var util in getStepUtils) {
if (getStepUtils.hasOwnProperty(util)) { if (getStepUtils.hasOwnProperty(util)) {
ref.images[image].steps[i][util] = getStepUtils[util]; ref.images[image].steps[i][util] = getStepUtils[util];
} }
} }
// Tell UI that a step is being drawn.
ref.images[image].steps[i].UI.onDraw(ref.images[image].steps[i].options.step);
ref.images[image].steps[i].draw( ref.images[image].steps[i].draw(
ref.copy(input), ref.copy(input),
function onEachStep() { function onEachStep() {
// This output is accessible by UI
ref.images[image].steps[i].options.step.output = ref.images[image].steps[i].output.src;
// Tell UI that step has been drawn.
ref.images[image].steps[i].UI.onComplete(ref.images[image].steps[i].options.step);
drawStep(drawarray, ++pos); drawStep(drawarray, ++pos);
}, },
progressObj progressObj
); );
} }
} }
function drawSteps(json_q) { function drawSteps(json_q) {
var drawarray = []; var drawarray = [];
for (var image in json_q) { for (var image in json_q) {
@@ -48068,7 +48083,7 @@ function Run(ref, json_q, callback,ind, progressObj) {
} }
drawStep(drawarray, ind); drawStep(drawarray, ind);
} }
function filter(json_q) { function filter(json_q) {
for (var image in json_q) { for (var image in json_q) {
if (json_q[image] == 0 && ref.images[image].steps.length == 1) if (json_q[image] == 0 && ref.images[image].steps.length == 1)
@@ -48086,7 +48101,7 @@ function Run(ref, json_q, callback,ind, progressObj) {
} }
return json_q; return json_q;
} }
var json_q = filter(json_q); var json_q = filter(json_q);
return drawSteps(json_q); return drawSteps(json_q);
} }
@@ -48097,30 +48112,24 @@ module.exports = Run;
* Average all pixel colors * Average all pixel colors
*/ */
module.exports = function Average(options, UI){ module.exports = function Average(options, UI){
options = options || {};
options.blur = options.blur || 2 options.blur = options.blur || 2
//Tell the UI that a step has been set up
UI.onSetup(options.step);
var output; var output;
options.step.metadata = options.step.metadata || {}; options.step.metadata = options.step.metadata || {};
function draw(input,callback,progressObj){ function draw(input,callback,progressObj){
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell the UI that a step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
function changePixel(r, g, b, a){ function changePixel(r, g, b, a){
return [r,g,b,a] return [r,g,b,a]
} }
// do the averaging // do the averaging
function extraManipulation(pixels){ function extraManipulation(pixels){
var sum = [0,0,0,0]; var sum = [0,0,0,0];
for (var i = 0; i < pixels.data.length; i += 4) { for (var i = 0; i < pixels.data.length; i += 4) {
@@ -48150,20 +48159,14 @@ module.exports = function Average(options, UI){
} }
function output(image, datauri, mimetype){ function output(image, datauri, mimetype){
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = { step.output = {
src: datauri, src: datauri,
format: mimetype 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, { return require('../_nomodule/PixelManipulation.js')(input, {
output: output, output: output,
changePixel: changePixel, changePixel: changePixel,
@@ -48172,7 +48175,7 @@ module.exports = function Average(options, UI){
image: options.image, image: options.image,
callback: callback callback: callback
}); });
} }
return { return {
options: options, options: options,
@@ -48193,11 +48196,8 @@ module.exports={
},{}],145:[function(require,module,exports){ },{}],145:[function(require,module,exports){
module.exports = function Dynamic(options, UI, util) { module.exports = function Dynamic(options, UI, util) {
options = options || {};
options.func = options.func || "function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }"; options.func = options.func || "function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }";
// Tell the UI that a step has been set up.
UI.onSetup(options.step);
var output; var output;
// This function is called on every draw. // This function is called on every draw.
@@ -48206,8 +48206,6 @@ module.exports = function Dynamic(options, UI, util) {
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell the UI that the step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
// convert to runnable code: // convert to runnable code:
@@ -48238,12 +48236,6 @@ module.exports = function Dynamic(options, UI, util) {
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = { src: datauri, format: mimetype }; step.output = { src: datauri, format: mimetype };
// This output is accessible by the UI
options.step.output = datauri;
// Tell the UI that the draw is complete
UI.onComplete(options.step);
} }
// run PixelManipulatin on second image's pixels // run PixelManipulatin on second image's pixels
@@ -48370,44 +48362,34 @@ function flipKernel(kernel){
* Blur an Image * Blur an Image
*/ */
module.exports = function Blur(options,UI){ module.exports = function Blur(options,UI){
options = options || {};
options.blur = options.blur || 2 options.blur = options.blur || 2
//Tell the UI that a step has been set up
UI.onSetup(options.step);
var output; var output;
function draw(input,callback,progressObj){ function draw(input,callback,progressObj){
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell the UI that a step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
function changePixel(r, g, b, a){ function changePixel(r, g, b, a){
return [r,g,b,a] return [r,g,b,a]
} }
function extraManipulation(pixels){ function extraManipulation(pixels){
pixels = require('./Blur')(pixels,options.blur) pixels = require('./Blur')(pixels,options.blur)
return pixels return pixels
} }
function output(image,datauri,mimetype){ function output(image,datauri,mimetype){
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = {src:datauri,format:mimetype}; 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, { return require('../_nomodule/PixelManipulation.js')(input, {
output: output, output: output,
changePixel: changePixel, changePixel: changePixel,
@@ -48416,7 +48398,7 @@ module.exports = function Blur(options,UI){
image: options.image, image: options.image,
callback: callback callback: callback
}); });
} }
return { return {
options: options, options: options,
@@ -48440,33 +48422,27 @@ module.exports={
} }
},{}],150:[function(require,module,exports){ },{}],150:[function(require,module,exports){
/* /*
* Changes the Image Brightness * Changes the Image Brightness
*/ */
module.exports = function Brightness(options,UI){ module.exports = function Brightness(options,UI){
options = options || {};
//Tell the UI that a step has been set up
UI.onSetup(options.step);
var output; var output;
function draw(input,callback,progressObj){ function draw(input,callback,progressObj){
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
/* /*
In this case progress is handled by changepixel internally otherwise progressObj In this case progress is handled by changepixel internally otherwise progressObj
needs to be overriden and used needs to be overriden and used
For eg. progressObj = new SomeProgressModule() For eg. progressObj = new SomeProgressModule()
*/ */
// Tell the UI that a step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
function changePixel(r, g, b, a){ function changePixel(r, g, b, a){
var val = (options.brightness)/100.0 var val = (options.brightness)/100.0
@@ -48475,19 +48451,14 @@ module.exports = function Brightness(options,UI){
b = val*b<255?val*b:255 b = val*b<255?val*b:255
return [r , g, b, a] return [r , g, b, a]
} }
function output(image,datauri,mimetype){ function output(image,datauri,mimetype){
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = {src:datauri,format:mimetype}; 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, { return require('../_nomodule/PixelManipulation.js')(input, {
output: output, output: output,
changePixel: changePixel, changePixel: changePixel,
@@ -48496,7 +48467,7 @@ module.exports = function Brightness(options,UI){
inBrowser: options.inBrowser, inBrowser: options.inBrowser,
callback: callback callback: callback
}); });
} }
return { return {
options: options, options: options,
@@ -48525,11 +48496,8 @@ module.exports={
*/ */
module.exports = function Channel(options,UI) { module.exports = function Channel(options,UI) {
options = options || {};
options.channel = options.channel || "green"; options.channel = options.channel || "green";
// Tell UI that a step has been set up
UI.onSetup(options.step);
var output; var output;
function draw(input,callback,progressObj) { function draw(input,callback,progressObj) {
@@ -48537,8 +48505,6 @@ module.exports = function Channel(options,UI) {
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell UI that a step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
function changePixel(r, g, b, a) { function changePixel(r, g, b, a) {
@@ -48552,11 +48518,6 @@ module.exports = function Channel(options,UI) {
// This output is accesible by Image Sequencer // This output is accesible by Image Sequencer
step.output = {src:datauri,format:mimetype}; 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, { return require('../_nomodule/PixelManipulation.js')(input, {
@@ -48685,10 +48646,6 @@ var colormaps = {
},{}],155:[function(require,module,exports){ },{}],155:[function(require,module,exports){
module.exports = function Colormap(options,UI) { module.exports = function Colormap(options,UI) {
options = options || {};
// Tell the UI that a step has been set up.
UI.onSetup(options.step);
var output; var output;
// This function is called on every draw. // This function is called on every draw.
@@ -48697,8 +48654,6 @@ module.exports = function Colormap(options,UI) {
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell the UI that the step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
function changePixel(r, g, b, a) { function changePixel(r, g, b, a) {
@@ -48712,12 +48667,6 @@ module.exports = function Colormap(options,UI) {
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = { src: datauri, format: mimetype }; step.output = { src: datauri, format: mimetype };
// This output is accessible by the UI
options.step.output = datauri;
// Tell the UI that the draw is complete
UI.onComplete(options.step);
} }
return require('../_nomodule/PixelManipulation.js')(input, { return require('../_nomodule/PixelManipulation.js')(input, {
output: output, output: output,
@@ -48763,8 +48712,8 @@ module.exports = function Crop(input,options,callback) {
options.y = parseInt(options.y) || 0; options.y = parseInt(options.y) || 0;
getPixels(input.src,function(err,pixels){ getPixels(input.src,function(err,pixels){
options.w = parseInt(options.w) || Math.floor(0.5*pixels.shape[0]); options.w = parseInt(options.w) || Math.floor(pixels.shape[0]);
options.h = parseInt(options.h) || Math.floor(0.5*pixels.shape[1]); options.h = parseInt(options.h) || Math.floor(pixels.shape[1]);
var ox = options.x; var ox = options.x;
var oy = options.y; var oy = options.y;
var w = options.w; var w = options.w;
@@ -48816,12 +48765,7 @@ module.exports = function Crop(input,options,callback) {
*/ */
module.exports = function CropModule(options, UI) { module.exports = function CropModule(options, UI) {
// TODO: we could also set this to {} if nil in AddModule.js to avoid this line: // we should get UI to return the image thumbnail so we can attach our own UI extensions
options = options || {};
// Tell the UI that a step has been added
UI.onSetup(options.step); // we should get UI to return the image thumbnail so we can attach our own UI extensions
// add our custom in-module html ui: // add our custom in-module html ui:
if (options.step.inBrowser) var ui = require('./Ui.js')(options.step, UI); if (options.step.inBrowser) var ui = require('./Ui.js')(options.step, UI);
var output, var output,
@@ -48830,11 +48774,9 @@ module.exports = function CropModule(options, UI) {
// This function is caled everytime the step has to be redrawn // This function is caled everytime the step has to be redrawn
function draw(input,callback) { function draw(input,callback) {
// Tell the UI that the step has been triggered
UI.onDraw(options.step);
var step = this; var step = this;
// save the input image; // save the input image;
// TODO: this should be moved to module API to persist the input image // TODO: this should be moved to module API to persist the input image
options.step.input = input.src; options.step.input = input.src;
@@ -48884,7 +48826,7 @@ module.exports = function CropModuleUi(step, ui) {
let inputWidth = 0, let inputWidth = 0,
inputHeight = 0; inputHeight = 0;
// We don't have input image dimensions at the // We don't have input image dimensions at the
// time of setting up the UI; that comes when draw() is triggered. // time of setting up the UI; that comes when draw() is triggered.
// So we trigger setup only on first run of draw() // So we trigger setup only on first run of draw()
// TODO: link this to an event rather than an explicit call in Module.js // TODO: link this to an event rather than an explicit call in Module.js
@@ -48893,7 +48835,7 @@ module.exports = function CropModuleUi(step, ui) {
y = 0; y = 0;
// display original uncropped input image on initial setup // display original uncropped input image on initial setup
showOriginal() showOriginal();
inputWidth = Math.floor(imgEl().naturalWidth); inputWidth = Math.floor(imgEl().naturalWidth);
inputHeight = Math.floor(imgEl().naturalHeight); inputHeight = Math.floor(imgEl().naturalHeight);
@@ -48995,27 +48937,21 @@ module.exports={
"w": { "w": {
"type": "integer", "type": "integer",
"desc": "Width of crop", "desc": "Width of crop",
"default": "(50%)" "default": "(100%)"
}, },
"h": { "h": {
"type": "integer", "type": "integer",
"desc": "Height of crop", "desc": "Height of crop",
"default": "(50%)" "default": "(100%)"
} }
} }
} }
},{}],161:[function(require,module,exports){ },{}],161:[function(require,module,exports){
/* /*
* Decodes QR from a given image. * Decodes QR from a given image.
*/ */
module.exports = function DoNothing(options,UI) { module.exports = function DoNothing(options,UI) {
options = options || {};
// Tell the UI that a step has been added
UI.onSetup(options.step);
var output; var output;
var jsQR = require('jsqr'); var jsQR = require('jsqr');
var getPixels = require('get-pixels'); var getPixels = require('get-pixels');
@@ -49023,8 +48959,6 @@ module.exports = function DoNothing(options,UI) {
// This function is called everytime a step has to be redrawn // This function is called everytime a step has to be redrawn
function draw(input,callback) { function draw(input,callback) {
UI.onDraw(options.step);
var step = this; var step = this;
getPixels(input.src,function(err,pixels){ getPixels(input.src,function(err,pixels){
@@ -49041,13 +48975,8 @@ module.exports = function DoNothing(options,UI) {
// Tell Image Sequencer that this step is complete // Tell Image Sequencer that this step is complete
callback(); callback();
// These values are accessible to the UI
options.step.output = input.src;
options.step.qrval = decoded; options.step.qrval = decoded;
// Tell the UI that the step is complete and output is set
UI.onComplete(options.step);
}); });
} }
@@ -49075,26 +49004,20 @@ module.exports={
},{}],163:[function(require,module,exports){ },{}],163:[function(require,module,exports){
module.exports = function Dynamic(options,UI) { module.exports = function Dynamic(options,UI) {
options = options || {};
// Tell the UI that a step has been set up.
UI.onSetup(options.step);
var output; var output;
// This function is called on every draw. // This function is called on every draw.
function draw(input,callback,progressObj) { function draw(input,callback,progressObj) {
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell the UI that the step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
// start with monochrome, but if options.red, options.green, and options.blue are set, accept them too // start with monochrome, but if options.red, options.green, and options.blue are set, accept them too
options.monochrome = options.monochrome || "(R+G+B)/3"; options.monochrome = options.monochrome || "(R+G+B)/3";
function generator(expression) { function generator(expression) {
var func = 'f = function (r, g, b, a) { var R = r, G = g, B = b, A = a;' var func = 'f = function (r, g, b, a) { var R = r, G = g, B = b, A = a;'
func = func + 'return '; func = func + 'return ';
@@ -49103,15 +49026,15 @@ module.exports = function Dynamic(options,UI) {
eval(func); eval(func);
return f; return f;
} }
var channels = ['red', 'green', 'blue', 'alpha']; var channels = ['red', 'green', 'blue', 'alpha'];
channels.forEach(function(channel) { channels.forEach(function(channel) {
if (options.hasOwnProperty(channel)) options[channel + '_function'] = generator(options[channel]); if (options.hasOwnProperty(channel)) options[channel + '_function'] = generator(options[channel]);
else if (channel === 'alpha') options['alpha_function'] = function() { return 255; } else if (channel === 'alpha') options['alpha_function'] = function() { return 255; }
else options[channel + '_function'] = generator(options.monochrome); else options[channel + '_function'] = generator(options.monochrome);
}); });
function changePixel(r, g, b, a) { function changePixel(r, g, b, a) {
/* neighbourpixels can be calculated by /* neighbourpixels can be calculated by
@@ -49125,7 +49048,7 @@ module.exports = function Dynamic(options,UI) {
options.alpha_function(r, g, b, a), options.alpha_function(r, g, b, a),
]; ];
} }
/* Functions to get the neighbouring pixel by position (x,y) */ /* Functions to get the neighbouring pixel by position (x,y) */
function getNeighbourPixel(pixels,curX,curY,distX,distY){ function getNeighbourPixel(pixels,curX,curY,distX,distY){
return [ return [
@@ -49135,19 +49058,13 @@ module.exports = function Dynamic(options,UI) {
,pixels.get(curX+distX,curY+distY,3) ,pixels.get(curX+distX,curY+distY,3)
] ]
} }
function output(image,datauri,mimetype){ function output(image,datauri,mimetype){
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = { src: datauri, format: mimetype }; step.output = { src: datauri, format: mimetype };
// This output is accessible by the UI
options.step.output = datauri;
// Tell the UI that the draw is complete
UI.onComplete(options.step);
} }
return require('../_nomodule/PixelManipulation.js')(input, { return require('../_nomodule/PixelManipulation.js')(input, {
output: output, output: output,
@@ -49159,9 +49076,9 @@ module.exports = function Dynamic(options,UI) {
inBrowser: options.inBrowser, inBrowser: options.inBrowser,
callback: callback callback: callback
}); });
} }
return { return {
options: options, options: options,
draw: draw, draw: draw,
@@ -49381,73 +49298,62 @@ function hysteresis(pixels){
},{"lodash":61}],166:[function(require,module,exports){ },{"lodash":61}],166:[function(require,module,exports){
/* /*
* Detect Edges in an Image * Detect Edges in an Image
*/ */
module.exports = function edgeDetect(options,UI) { module.exports = function edgeDetect(options,UI) {
options = options || {}; options.blur = options.blur || 2;
options.blur = options.blur || 2 options.highThresholdRatio = options.highThresholdRatio||0.2;
options.highThresholdRatio = options.highThresholdRatio||0.2 options.lowThresholdRatio = options.lowThresholdRatio||0.15;
options.lowThresholdRatio = options.lowThresholdRatio||0.15
// 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) {
progressObj.stop(true);
progressObj.overrideFlag = true;
// Tell UI that a step is being drawn. var output;
UI.onDraw(options.step);
// The function which is called on every draw.
var step = this; function draw(input,callback,progressObj) {
progressObj.stop(true);
progressObj.overrideFlag = true;
var step = this;
// Extra Manipulation function used as an enveloper for applying gaussian blur and Convolution // Extra Manipulation function used as an enveloper for applying gaussian blur and Convolution
function extraManipulation(pixels){ function extraManipulation(pixels){
pixels = require('ndarray-gaussian-filter')(pixels,options.blur) pixels = require('ndarray-gaussian-filter')(pixels,options.blur);
return require('./EdgeUtils')(pixels,options.highThresholdRatio,options.lowThresholdRatio,options.inBrowser) return require('./EdgeUtils')(pixels,options.highThresholdRatio,options.lowThresholdRatio,options.inBrowser);
}
function changePixel(r, g, b, a) {
return [(r+g+b)/3, (r+g+b)/3, (r+g+b)/3, 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,
extraManipulation: extraManipulation,
format: input.format,
image: options.image,
inBrowser: options.inBrowser,
callback: callback
});
} }
return { function changePixel(r, g, b, a) {
options: options, return [(r+g+b)/3, (r+g+b)/3, (r+g+b)/3, a];
draw: draw, }
function output(image,datauri,mimetype){
// This output is accessible by Image Sequencer
step.output = {src:datauri,format:mimetype};
}
return require('../_nomodule/PixelManipulation.js')(input, {
output: output, output: output,
UI: UI changePixel: changePixel,
} extraManipulation: extraManipulation,
format: input.format,
image: options.image,
inBrowser: options.inBrowser,
callback: callback
});
} }
return {
options: options,
draw: draw,
output: output,
UI: UI
}
}
},{"../_nomodule/PixelManipulation.js":179,"./EdgeUtils":165,"ndarray-gaussian-filter":66}],167:[function(require,module,exports){ },{"../_nomodule/PixelManipulation.js":179,"./EdgeUtils":165,"ndarray-gaussian-filter":66}],167:[function(require,module,exports){
module.exports={ module.exports={
"name": "Detect Edges", "name": "Detect Edges",
@@ -49477,18 +49383,12 @@ module.exports={
*/ */
module.exports = function DoNothing(options,UI) { module.exports = function DoNothing(options,UI) {
options = options || {};
var output; var output;
// Tell the UI that a step has been set up.
UI.onSetup(options.step);
require('fisheyegl'); require('fisheyegl');
function draw(input,callback) { function draw(input,callback) {
// Tell the UI that the step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
if (!options.inBrowser) { // This module is only for browser if (!options.inBrowser) { // This module is only for browser
@@ -49533,13 +49433,9 @@ module.exports = function DoNothing(options,UI) {
// this output is accessible to Image Sequencer // this output is accessible to Image Sequencer
step.output = {src: canvas.toDataURL(), format: input.format}; step.output = {src: canvas.toDataURL(), format: input.format};
// This output is accessible to the UI
options.step.output = step.output.src;
// Tell Image Sequencer and UI that step has been drawn // Tell Image Sequencer and UI that step has been drawn
callback(); callback();
UI.onComplete(options.step);
}); });
} }
@@ -49632,14 +49528,12 @@ module.exports={
*/ */
module.exports = function ImportImageModule(options, UI) { module.exports = function ImportImageModule(options, UI) {
options = options || {};
options.imageUrl = options.url || "./images/monarch.png"; options.imageUrl = options.url || "./images/monarch.png";
var output, var output,
imgObj = new Image(); imgObj = new Image();
// Tell the UI that a step has been added // we should get UI to return the image thumbnail so we can attach our own UI extensions
UI.onSetup(options.step); // we should get UI to return the image thumbnail so we can attach our own UI extensions
// add our custom in-module html ui: // add our custom in-module html ui:
if (options.step.inBrowser) { if (options.step.inBrowser) {
@@ -49650,8 +49544,6 @@ module.exports = function ImportImageModule(options, UI) {
// This function is caled everytime the step has to be redrawn // This function is caled everytime the step has to be redrawn
function draw(input,callback) { function draw(input,callback) {
// Tell the UI that the step has been triggered
UI.onDraw(options.step);
var step = this; var step = this;
step.metadata = step.metadata || {}; step.metadata = step.metadata || {};
@@ -49667,12 +49559,6 @@ module.exports = function ImportImageModule(options, UI) {
format: options.format format: options.format
} }
// This output is accessible to the UI
options.step.output = imgObj.src;
// Tell the UI that the step has been drawn
UI.onComplete(options.step);
// Tell Image Sequencer that step has been drawn // Tell Image Sequencer that step has been drawn
callback(); callback();
} }
@@ -49766,10 +49652,6 @@ module.exports={
*/ */
module.exports = function Invert(options, UI) { module.exports = function Invert(options, UI) {
options = options || {};
// Tell UI that a step has been set up.
UI.onSetup(options.step);
var output; var output;
// The function which is called on every draw. // The function which is called on every draw.
@@ -49777,8 +49659,6 @@ module.exports = function Invert(options, UI) {
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell UI that a step is being drawn.
UI.onDraw(options.step);
var step = this; var step = this;
@@ -49791,11 +49671,6 @@ module.exports = function Invert(options, UI) {
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = { src: datauri, format: mimetype }; 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, { return require('../_nomodule/PixelManipulation.js')(input, {
@@ -49831,11 +49706,8 @@ module.exports={
*/ */
module.exports = function Ndvi(options,UI) { module.exports = function Ndvi(options,UI) {
options = options || {};
options.filter = options.filter || "red"; options.filter = options.filter || "red";
// Tell the UI that a step has been set up.
UI.onSetup(options.step);
var output; var output;
// The function which is called on every draw. // The function which is called on every draw.
@@ -49844,8 +49716,6 @@ module.exports = function Ndvi(options,UI) {
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell the UI that a step is being drawn.
UI.onDraw(options.step);
var step = this; var step = this;
function changePixel(r, g, b, a) { function changePixel(r, g, b, a) {
@@ -49860,13 +49730,8 @@ module.exports = function Ndvi(options,UI) {
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = {src:datauri,format:mimetype}; step.output = {src:datauri,format:mimetype};
// This output is accessible by the UI.
options.step.output = datauri;
// Tell the UI that step has been drawn succesfully.
UI.onComplete(options.step);
} }
return require('../_nomodule/PixelManipulation.js')(input, { return require('../_nomodule/PixelManipulation.js')(input, {
output: output, output: output,
changePixel: changePixel, changePixel: changePixel,
@@ -49906,10 +49771,6 @@ module.exports={
*/ */
module.exports = function Saturation(options,UI) { module.exports = function Saturation(options,UI) {
options = options || {};
// Tell UI that a step has been set up
UI.onSetup(options.step);
var output; var output;
function draw(input,callback,progressObj) { function draw(input,callback,progressObj) {
@@ -49917,8 +49778,6 @@ module.exports = function Saturation(options,UI) {
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell UI that a step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
function changePixel(r, g, b, a) { function changePixel(r, g, b, a) {
@@ -49942,11 +49801,6 @@ module.exports = function Saturation(options,UI) {
// This output is accesible by Image Sequencer // This output is accesible by Image Sequencer
step.output = {src:datauri,format:mimetype}; 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, { return require('../_nomodule/PixelManipulation.js')(input, {
@@ -50304,9 +50158,9 @@ module.exports = function GetFormat(src) {
var format = undefined; // haha default var format = undefined; // haha default
// EXAMPLE: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAQABADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABykX//Z"; // EXAMPLE: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAQABADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABykX//Z";
// EXAMPLE: "http://example.com/example.png" // EXAMPLE: "http://example.com/example.png"
// EXAMPLE: "/example.png" // EXAMPLE: "/example.png"
if (isDataUrl(src)) { if (isDataUrl(src)) {
format = src.split(';')[0].split('/').pop(); format = src.split(';')[0].split('/').pop();
} else { } else {
@@ -50330,16 +50184,16 @@ module.exports = {
getPreviousStep : function () { getPreviousStep : function () {
return this.getStep(-1); return this.getStep(-1);
}, },
getNextStep : function() { getNextStep : function() {
return this.getStep(1); return this.getStep(1);
}, },
getInput : function(offset){ getInput : function(offset){
if(offset + this.getIndex() === 0) offset++; if(offset + this.getIndex() === 0) offset++;
return this.getStep(offset - 1).output; return this.getStep(offset - 1).output;
}, },
getOuput : function(offset){ getOuput : function(offset){
return this.getStep(offset).output; return this.getStep(offset).output;
} }

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
// add steps to the sequencer // add steps to the sequencer
// TODO: reduce redundancy with InsertStep; this should be a specific usage of InsertStep at the final position // TODO: reduce redundancy with InsertStep; this should be a specific usage of InsertStep at the final position
function AddStep(_sequencer, image, name, o) { function AddStep(_sequencer, image, name, o) {
@@ -25,7 +25,12 @@ function AddStep(_sequencer, image, name, o) {
options: o options: o
}; };
var UI = _sequencer.events; var UI = _sequencer.events;
// Tell UI that a step has been set up.
o = o || {};
UI.onSetup(o.step);
var module = _sequencer.modules[name][0](o, UI); var module = _sequencer.modules[name][0](o, UI);
_sequencer.images[image].steps.push(module); _sequencer.images[image].steps.push(module);
return true; return true;

View File

@@ -2,7 +2,7 @@ const fs = require('fs')
/* /*
* This function checks if the directory exists, if not it creates one on the given path * This function checks if the directory exists, if not it creates one on the given path
* Callback is called with argument error if an error is encountered * Callback is called with argument error if an error is encountered
*/ */

View File

@@ -1,5 +1,5 @@
// Uses a given image as input and replaces it with the output. // Uses a given image as input and replaces it with the output.
// Works only in the browser. // Works only in the browser.
function ReplaceImage(ref,selector,steps,options) { function ReplaceImage(ref,selector,steps,options) {
if(!ref.options.inBrowser) return false; // This isn't for Node.js if(!ref.options.inBrowser) return false; // This isn't for Node.js
var tempSequencer = ImageSequencer({ui: false}); var tempSequencer = ImageSequencer({ui: false});

View File

@@ -2,7 +2,7 @@ const getStepUtils = require('./util/getStep.js');
function Run(ref, json_q, callback,ind, progressObj) { function Run(ref, json_q, callback,ind, progressObj) {
if (!progressObj) progressObj = { stop: function () { } }; if (!progressObj) progressObj = { stop: function () { } };
function drawStep(drawarray, pos) { function drawStep(drawarray, pos) {
if (pos == drawarray.length && drawarray[pos - 1] !== undefined) { if (pos == drawarray.length && drawarray[pos - 1] !== undefined) {
var image = drawarray[pos - 1].image; var image = drawarray[pos - 1].image;
@@ -13,13 +13,13 @@ function Run(ref, json_q, callback,ind, progressObj) {
return true; return true;
} }
} }
// so we don't run on the loadImage module: // so we don't run on the loadImage module:
if (drawarray[pos] !== undefined) { if (drawarray[pos] !== undefined) {
var image = drawarray[pos].image; var image = drawarray[pos].image;
var i = drawarray[pos].i; var i = drawarray[pos].i;
var input = ref.images[image].steps[i - 1].output; var input = ref.images[image].steps[i - 1].output;
ref.images[image].steps[i].getStep = function getStep(offset) { ref.images[image].steps[i].getStep = function getStep(offset) {
if(i + offset >= ref.images[image].steps.length) return {options:{name:undefined}}; if(i + offset >= ref.images[image].steps.length) return {options:{name:undefined}};
else return ref.images[image].steps.slice(i + offset)[0]; else return ref.images[image].steps.slice(i + offset)[0];
@@ -27,23 +27,33 @@ function Run(ref, json_q, callback,ind, progressObj) {
ref.images[image].steps[i].getIndex = function getIndex(){ ref.images[image].steps[i].getIndex = function getIndex(){
return i; return i;
} }
for (var util in getStepUtils) { for (var util in getStepUtils) {
if (getStepUtils.hasOwnProperty(util)) { if (getStepUtils.hasOwnProperty(util)) {
ref.images[image].steps[i][util] = getStepUtils[util]; ref.images[image].steps[i][util] = getStepUtils[util];
} }
} }
// Tell UI that a step is being drawn.
ref.images[image].steps[i].UI.onDraw(ref.images[image].steps[i].options.step);
ref.images[image].steps[i].draw( ref.images[image].steps[i].draw(
ref.copy(input), ref.copy(input),
function onEachStep() { function onEachStep() {
// This output is accessible by UI
ref.images[image].steps[i].options.step.output = ref.images[image].steps[i].output.src;
// Tell UI that step has been drawn.
ref.images[image].steps[i].UI.onComplete(ref.images[image].steps[i].options.step);
drawStep(drawarray, ++pos); drawStep(drawarray, ++pos);
}, },
progressObj progressObj
); );
} }
} }
function drawSteps(json_q) { function drawSteps(json_q) {
var drawarray = []; var drawarray = [];
for (var image in json_q) { for (var image in json_q) {
@@ -55,7 +65,7 @@ function Run(ref, json_q, callback,ind, progressObj) {
} }
drawStep(drawarray, ind); drawStep(drawarray, ind);
} }
function filter(json_q) { function filter(json_q) {
for (var image in json_q) { for (var image in json_q) {
if (json_q[image] == 0 && ref.images[image].steps.length == 1) if (json_q[image] == 0 && ref.images[image].steps.length == 1)
@@ -73,7 +83,7 @@ function Run(ref, json_q, callback,ind, progressObj) {
} }
return json_q; return json_q;
} }
var json_q = filter(json_q); var json_q = filter(json_q);
return drawSteps(json_q); return drawSteps(json_q);
} }

View File

@@ -2,30 +2,24 @@
* Average all pixel colors * Average all pixel colors
*/ */
module.exports = function Average(options, UI){ module.exports = function Average(options, UI){
options = options || {};
options.blur = options.blur || 2 options.blur = options.blur || 2
//Tell the UI that a step has been set up
UI.onSetup(options.step);
var output; var output;
options.step.metadata = options.step.metadata || {}; options.step.metadata = options.step.metadata || {};
function draw(input,callback,progressObj){ function draw(input,callback,progressObj){
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell the UI that a step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
function changePixel(r, g, b, a){ function changePixel(r, g, b, a){
return [r,g,b,a] return [r,g,b,a]
} }
// do the averaging // do the averaging
function extraManipulation(pixels){ function extraManipulation(pixels){
var sum = [0,0,0,0]; var sum = [0,0,0,0];
for (var i = 0; i < pixels.data.length; i += 4) { for (var i = 0; i < pixels.data.length; i += 4) {
@@ -55,20 +49,14 @@ module.exports = function Average(options, UI){
} }
function output(image, datauri, mimetype){ function output(image, datauri, mimetype){
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = { step.output = {
src: datauri, src: datauri,
format: mimetype 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, { return require('../_nomodule/PixelManipulation.js')(input, {
output: output, output: output,
changePixel: changePixel, changePixel: changePixel,
@@ -77,7 +65,7 @@ module.exports = function Average(options, UI){
image: options.image, image: options.image,
callback: callback callback: callback
}); });
} }
return { return {
options: options, options: options,

View File

@@ -1,10 +1,7 @@
module.exports = function Dynamic(options, UI, util) { module.exports = function Dynamic(options, UI, util) {
options = options || {};
options.func = options.func || "function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }"; options.func = options.func || "function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }";
// Tell the UI that a step has been set up.
UI.onSetup(options.step);
var output; var output;
// This function is called on every draw. // This function is called on every draw.
@@ -13,8 +10,6 @@ module.exports = function Dynamic(options, UI, util) {
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell the UI that the step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
// convert to runnable code: // convert to runnable code:
@@ -45,12 +40,6 @@ module.exports = function Dynamic(options, UI, util) {
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = { src: datauri, format: mimetype }; step.output = { src: datauri, format: mimetype };
// This output is accessible by the UI
options.step.output = datauri;
// Tell the UI that the draw is complete
UI.onComplete(options.step);
} }
// run PixelManipulatin on second image's pixels // run PixelManipulatin on second image's pixels

View File

@@ -2,44 +2,34 @@
* Blur an Image * Blur an Image
*/ */
module.exports = function Blur(options,UI){ module.exports = function Blur(options,UI){
options = options || {};
options.blur = options.blur || 2 options.blur = options.blur || 2
//Tell the UI that a step has been set up
UI.onSetup(options.step);
var output; var output;
function draw(input,callback,progressObj){ function draw(input,callback,progressObj){
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell the UI that a step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
function changePixel(r, g, b, a){ function changePixel(r, g, b, a){
return [r,g,b,a] return [r,g,b,a]
} }
function extraManipulation(pixels){ function extraManipulation(pixels){
pixels = require('./Blur')(pixels,options.blur) pixels = require('./Blur')(pixels,options.blur)
return pixels return pixels
} }
function output(image,datauri,mimetype){ function output(image,datauri,mimetype){
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = {src:datauri,format:mimetype}; 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, { return require('../_nomodule/PixelManipulation.js')(input, {
output: output, output: output,
changePixel: changePixel, changePixel: changePixel,
@@ -48,7 +38,7 @@ module.exports = function Blur(options,UI){
image: options.image, image: options.image,
callback: callback callback: callback
}); });
} }
return { return {
options: options, options: options,

View File

@@ -1,30 +1,24 @@
/* /*
* Changes the Image Brightness * Changes the Image Brightness
*/ */
module.exports = function Brightness(options,UI){ module.exports = function Brightness(options,UI){
options = options || {};
//Tell the UI that a step has been set up
UI.onSetup(options.step);
var output; var output;
function draw(input,callback,progressObj){ function draw(input,callback,progressObj){
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
/* /*
In this case progress is handled by changepixel internally otherwise progressObj In this case progress is handled by changepixel internally otherwise progressObj
needs to be overriden and used needs to be overriden and used
For eg. progressObj = new SomeProgressModule() For eg. progressObj = new SomeProgressModule()
*/ */
// Tell the UI that a step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
function changePixel(r, g, b, a){ function changePixel(r, g, b, a){
var val = (options.brightness)/100.0 var val = (options.brightness)/100.0
@@ -33,19 +27,14 @@ module.exports = function Brightness(options,UI){
b = val*b<255?val*b:255 b = val*b<255?val*b:255
return [r , g, b, a] return [r , g, b, a]
} }
function output(image,datauri,mimetype){ function output(image,datauri,mimetype){
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = {src:datauri,format:mimetype}; 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, { return require('../_nomodule/PixelManipulation.js')(input, {
output: output, output: output,
changePixel: changePixel, changePixel: changePixel,
@@ -54,7 +43,7 @@ module.exports = function Brightness(options,UI){
inBrowser: options.inBrowser, inBrowser: options.inBrowser,
callback: callback callback: callback
}); });
} }
return { return {
options: options, options: options,

View File

@@ -3,11 +3,8 @@
*/ */
module.exports = function Channel(options,UI) { module.exports = function Channel(options,UI) {
options = options || {};
options.channel = options.channel || "green"; options.channel = options.channel || "green";
// Tell UI that a step has been set up
UI.onSetup(options.step);
var output; var output;
function draw(input,callback,progressObj) { function draw(input,callback,progressObj) {
@@ -15,8 +12,6 @@ module.exports = function Channel(options,UI) {
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell UI that a step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
function changePixel(r, g, b, a) { function changePixel(r, g, b, a) {
@@ -30,11 +25,6 @@ module.exports = function Channel(options,UI) {
// This output is accesible by Image Sequencer // This output is accesible by Image Sequencer
step.output = {src:datauri,format:mimetype}; 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, { return require('../_nomodule/PixelManipulation.js')(input, {

View File

@@ -1,9 +1,5 @@
module.exports = function Colormap(options,UI) { module.exports = function Colormap(options,UI) {
options = options || {};
// Tell the UI that a step has been set up.
UI.onSetup(options.step);
var output; var output;
// This function is called on every draw. // This function is called on every draw.
@@ -12,8 +8,6 @@ module.exports = function Colormap(options,UI) {
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell the UI that the step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
function changePixel(r, g, b, a) { function changePixel(r, g, b, a) {
@@ -27,12 +21,6 @@ module.exports = function Colormap(options,UI) {
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = { src: datauri, format: mimetype }; step.output = { src: datauri, format: mimetype };
// This output is accessible by the UI
options.step.output = datauri;
// Tell the UI that the draw is complete
UI.onComplete(options.step);
} }
return require('../_nomodule/PixelManipulation.js')(input, { return require('../_nomodule/PixelManipulation.js')(input, {
output: output, output: output,

View File

@@ -7,8 +7,8 @@ module.exports = function Crop(input,options,callback) {
options.y = parseInt(options.y) || 0; options.y = parseInt(options.y) || 0;
getPixels(input.src,function(err,pixels){ getPixels(input.src,function(err,pixels){
options.w = parseInt(options.w) || Math.floor(0.5*pixels.shape[0]); options.w = parseInt(options.w) || Math.floor(pixels.shape[0]);
options.h = parseInt(options.h) || Math.floor(0.5*pixels.shape[1]); options.h = parseInt(options.h) || Math.floor(pixels.shape[1]);
var ox = options.x; var ox = options.x;
var oy = options.y; var oy = options.y;
var w = options.w; var w = options.w;

View File

@@ -15,12 +15,7 @@
*/ */
module.exports = function CropModule(options, UI) { module.exports = function CropModule(options, UI) {
// TODO: we could also set this to {} if nil in AddModule.js to avoid this line: // we should get UI to return the image thumbnail so we can attach our own UI extensions
options = options || {};
// Tell the UI that a step has been added
UI.onSetup(options.step); // we should get UI to return the image thumbnail so we can attach our own UI extensions
// add our custom in-module html ui: // add our custom in-module html ui:
if (options.step.inBrowser) var ui = require('./Ui.js')(options.step, UI); if (options.step.inBrowser) var ui = require('./Ui.js')(options.step, UI);
var output, var output,
@@ -29,11 +24,9 @@ module.exports = function CropModule(options, UI) {
// This function is caled everytime the step has to be redrawn // This function is caled everytime the step has to be redrawn
function draw(input,callback) { function draw(input,callback) {
// Tell the UI that the step has been triggered
UI.onDraw(options.step);
var step = this; var step = this;
// save the input image; // save the input image;
// TODO: this should be moved to module API to persist the input image // TODO: this should be moved to module API to persist the input image
options.step.input = input.src; options.step.input = input.src;

View File

@@ -4,7 +4,7 @@ module.exports = function CropModuleUi(step, ui) {
let inputWidth = 0, let inputWidth = 0,
inputHeight = 0; inputHeight = 0;
// We don't have input image dimensions at the // We don't have input image dimensions at the
// time of setting up the UI; that comes when draw() is triggered. // time of setting up the UI; that comes when draw() is triggered.
// So we trigger setup only on first run of draw() // So we trigger setup only on first run of draw()
// TODO: link this to an event rather than an explicit call in Module.js // TODO: link this to an event rather than an explicit call in Module.js
@@ -13,7 +13,7 @@ module.exports = function CropModuleUi(step, ui) {
y = 0; y = 0;
// display original uncropped input image on initial setup // display original uncropped input image on initial setup
showOriginal() showOriginal();
inputWidth = Math.floor(imgEl().naturalWidth); inputWidth = Math.floor(imgEl().naturalWidth);
inputHeight = Math.floor(imgEl().naturalHeight); inputHeight = Math.floor(imgEl().naturalHeight);

View File

@@ -16,12 +16,12 @@
"w": { "w": {
"type": "integer", "type": "integer",
"desc": "Width of crop", "desc": "Width of crop",
"default": "(50%)" "default": "(100%)"
}, },
"h": { "h": {
"type": "integer", "type": "integer",
"desc": "Height of crop", "desc": "Height of crop",
"default": "(50%)" "default": "(100%)"
} }
} }
} }

View File

@@ -3,11 +3,6 @@
*/ */
module.exports = function DoNothing(options,UI) { module.exports = function DoNothing(options,UI) {
options = options || {};
// Tell the UI that a step has been added
UI.onSetup(options.step);
var output; var output;
var jsQR = require('jsqr'); var jsQR = require('jsqr');
var getPixels = require('get-pixels'); var getPixels = require('get-pixels');
@@ -15,8 +10,6 @@ module.exports = function DoNothing(options,UI) {
// This function is called everytime a step has to be redrawn // This function is called everytime a step has to be redrawn
function draw(input,callback) { function draw(input,callback) {
UI.onDraw(options.step);
var step = this; var step = this;
getPixels(input.src,function(err,pixels){ getPixels(input.src,function(err,pixels){
@@ -33,13 +26,8 @@ module.exports = function DoNothing(options,UI) {
// Tell Image Sequencer that this step is complete // Tell Image Sequencer that this step is complete
callback(); callback();
// These values are accessible to the UI
options.step.output = input.src;
options.step.qrval = decoded; options.step.qrval = decoded;
// Tell the UI that the step is complete and output is set
UI.onComplete(options.step);
}); });
} }

View File

@@ -1,24 +1,18 @@
module.exports = function Dynamic(options,UI) { module.exports = function Dynamic(options,UI) {
options = options || {};
// Tell the UI that a step has been set up.
UI.onSetup(options.step);
var output; var output;
// This function is called on every draw. // This function is called on every draw.
function draw(input,callback,progressObj) { function draw(input,callback,progressObj) {
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell the UI that the step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
// start with monochrome, but if options.red, options.green, and options.blue are set, accept them too // start with monochrome, but if options.red, options.green, and options.blue are set, accept them too
options.monochrome = options.monochrome || "(R+G+B)/3"; options.monochrome = options.monochrome || "(R+G+B)/3";
function generator(expression) { function generator(expression) {
var func = 'f = function (r, g, b, a) { var R = r, G = g, B = b, A = a;' var func = 'f = function (r, g, b, a) { var R = r, G = g, B = b, A = a;'
func = func + 'return '; func = func + 'return ';
@@ -27,15 +21,15 @@ module.exports = function Dynamic(options,UI) {
eval(func); eval(func);
return f; return f;
} }
var channels = ['red', 'green', 'blue', 'alpha']; var channels = ['red', 'green', 'blue', 'alpha'];
channels.forEach(function(channel) { channels.forEach(function(channel) {
if (options.hasOwnProperty(channel)) options[channel + '_function'] = generator(options[channel]); if (options.hasOwnProperty(channel)) options[channel + '_function'] = generator(options[channel]);
else if (channel === 'alpha') options['alpha_function'] = function() { return 255; } else if (channel === 'alpha') options['alpha_function'] = function() { return 255; }
else options[channel + '_function'] = generator(options.monochrome); else options[channel + '_function'] = generator(options.monochrome);
}); });
function changePixel(r, g, b, a) { function changePixel(r, g, b, a) {
/* neighbourpixels can be calculated by /* neighbourpixels can be calculated by
@@ -49,7 +43,7 @@ module.exports = function Dynamic(options,UI) {
options.alpha_function(r, g, b, a), options.alpha_function(r, g, b, a),
]; ];
} }
/* Functions to get the neighbouring pixel by position (x,y) */ /* Functions to get the neighbouring pixel by position (x,y) */
function getNeighbourPixel(pixels,curX,curY,distX,distY){ function getNeighbourPixel(pixels,curX,curY,distX,distY){
return [ return [
@@ -59,19 +53,13 @@ module.exports = function Dynamic(options,UI) {
,pixels.get(curX+distX,curY+distY,3) ,pixels.get(curX+distX,curY+distY,3)
] ]
} }
function output(image,datauri,mimetype){ function output(image,datauri,mimetype){
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = { src: datauri, format: mimetype }; step.output = { src: datauri, format: mimetype };
// This output is accessible by the UI
options.step.output = datauri;
// Tell the UI that the draw is complete
UI.onComplete(options.step);
} }
return require('../_nomodule/PixelManipulation.js')(input, { return require('../_nomodule/PixelManipulation.js')(input, {
output: output, output: output,
@@ -83,9 +71,9 @@ module.exports = function Dynamic(options,UI) {
inBrowser: options.inBrowser, inBrowser: options.inBrowser,
callback: callback callback: callback
}); });
} }
return { return {
options: options, options: options,
draw: draw, draw: draw,

View File

@@ -1,67 +1,56 @@
/* /*
* Detect Edges in an Image * Detect Edges in an Image
*/ */
module.exports = function edgeDetect(options,UI) { module.exports = function edgeDetect(options,UI) {
options = options || {}; options.blur = options.blur || 2;
options.blur = options.blur || 2 options.highThresholdRatio = options.highThresholdRatio||0.2;
options.highThresholdRatio = options.highThresholdRatio||0.2 options.lowThresholdRatio = options.lowThresholdRatio||0.15;
options.lowThresholdRatio = options.lowThresholdRatio||0.15
// 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) {
progressObj.stop(true);
progressObj.overrideFlag = true;
// Tell UI that a step is being drawn. var output;
UI.onDraw(options.step);
// The function which is called on every draw.
var step = this; function draw(input,callback,progressObj) {
progressObj.stop(true);
progressObj.overrideFlag = true;
var step = this;
// Extra Manipulation function used as an enveloper for applying gaussian blur and Convolution // Extra Manipulation function used as an enveloper for applying gaussian blur and Convolution
function extraManipulation(pixels){ function extraManipulation(pixels){
pixels = require('ndarray-gaussian-filter')(pixels,options.blur) pixels = require('ndarray-gaussian-filter')(pixels,options.blur);
return require('./EdgeUtils')(pixels,options.highThresholdRatio,options.lowThresholdRatio,options.inBrowser) return require('./EdgeUtils')(pixels,options.highThresholdRatio,options.lowThresholdRatio,options.inBrowser);
}
function changePixel(r, g, b, a) {
return [(r+g+b)/3, (r+g+b)/3, (r+g+b)/3, 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,
extraManipulation: extraManipulation,
format: input.format,
image: options.image,
inBrowser: options.inBrowser,
callback: callback
});
} }
return { function changePixel(r, g, b, a) {
options: options, return [(r+g+b)/3, (r+g+b)/3, (r+g+b)/3, a];
draw: draw, }
function output(image,datauri,mimetype){
// This output is accessible by Image Sequencer
step.output = {src:datauri,format:mimetype};
}
return require('../_nomodule/PixelManipulation.js')(input, {
output: output, output: output,
UI: UI changePixel: changePixel,
} extraManipulation: extraManipulation,
format: input.format,
image: options.image,
inBrowser: options.inBrowser,
callback: callback
});
} }
return {
options: options,
draw: draw,
output: output,
UI: UI
}
}

View File

@@ -3,18 +3,12 @@
*/ */
module.exports = function DoNothing(options,UI) { module.exports = function DoNothing(options,UI) {
options = options || {};
var output; var output;
// Tell the UI that a step has been set up.
UI.onSetup(options.step);
require('fisheyegl'); require('fisheyegl');
function draw(input,callback) { function draw(input,callback) {
// Tell the UI that the step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
if (!options.inBrowser) { // This module is only for browser if (!options.inBrowser) { // This module is only for browser
@@ -59,13 +53,9 @@ module.exports = function DoNothing(options,UI) {
// this output is accessible to Image Sequencer // this output is accessible to Image Sequencer
step.output = {src: canvas.toDataURL(), format: input.format}; step.output = {src: canvas.toDataURL(), format: input.format};
// This output is accessible to the UI
options.step.output = step.output.src;
// Tell Image Sequencer and UI that step has been drawn // Tell Image Sequencer and UI that step has been drawn
callback(); callback();
UI.onComplete(options.step);
}); });
} }

View File

@@ -8,14 +8,12 @@
*/ */
module.exports = function ImportImageModule(options, UI) { module.exports = function ImportImageModule(options, UI) {
options = options || {};
options.imageUrl = options.url || "./images/monarch.png"; options.imageUrl = options.url || "./images/monarch.png";
var output, var output,
imgObj = new Image(); imgObj = new Image();
// Tell the UI that a step has been added // we should get UI to return the image thumbnail so we can attach our own UI extensions
UI.onSetup(options.step); // we should get UI to return the image thumbnail so we can attach our own UI extensions
// add our custom in-module html ui: // add our custom in-module html ui:
if (options.step.inBrowser) { if (options.step.inBrowser) {
@@ -26,8 +24,6 @@ module.exports = function ImportImageModule(options, UI) {
// This function is caled everytime the step has to be redrawn // This function is caled everytime the step has to be redrawn
function draw(input,callback) { function draw(input,callback) {
// Tell the UI that the step has been triggered
UI.onDraw(options.step);
var step = this; var step = this;
step.metadata = step.metadata || {}; step.metadata = step.metadata || {};
@@ -43,12 +39,6 @@ module.exports = function ImportImageModule(options, UI) {
format: options.format format: options.format
} }
// This output is accessible to the UI
options.step.output = imgObj.src;
// Tell the UI that the step has been drawn
UI.onComplete(options.step);
// Tell Image Sequencer that step has been drawn // Tell Image Sequencer that step has been drawn
callback(); callback();
} }

View File

@@ -3,10 +3,6 @@
*/ */
module.exports = function Invert(options, UI) { module.exports = function Invert(options, UI) {
options = options || {};
// Tell UI that a step has been set up.
UI.onSetup(options.step);
var output; var output;
// The function which is called on every draw. // The function which is called on every draw.
@@ -14,8 +10,6 @@ module.exports = function Invert(options, UI) {
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell UI that a step is being drawn.
UI.onDraw(options.step);
var step = this; var step = this;
@@ -28,11 +22,6 @@ module.exports = function Invert(options, UI) {
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = { src: datauri, format: mimetype }; 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, { return require('../_nomodule/PixelManipulation.js')(input, {

View File

@@ -3,11 +3,8 @@
*/ */
module.exports = function Ndvi(options,UI) { module.exports = function Ndvi(options,UI) {
options = options || {};
options.filter = options.filter || "red"; options.filter = options.filter || "red";
// Tell the UI that a step has been set up.
UI.onSetup(options.step);
var output; var output;
// The function which is called on every draw. // The function which is called on every draw.
@@ -16,8 +13,6 @@ module.exports = function Ndvi(options,UI) {
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell the UI that a step is being drawn.
UI.onDraw(options.step);
var step = this; var step = this;
function changePixel(r, g, b, a) { function changePixel(r, g, b, a) {
@@ -32,13 +27,8 @@ module.exports = function Ndvi(options,UI) {
// This output is accessible by Image Sequencer // This output is accessible by Image Sequencer
step.output = {src:datauri,format:mimetype}; step.output = {src:datauri,format:mimetype};
// This output is accessible by the UI.
options.step.output = datauri;
// Tell the UI that step has been drawn succesfully.
UI.onComplete(options.step);
} }
return require('../_nomodule/PixelManipulation.js')(input, { return require('../_nomodule/PixelManipulation.js')(input, {
output: output, output: output,
changePixel: changePixel, changePixel: changePixel,

View File

@@ -3,10 +3,6 @@
*/ */
module.exports = function Saturation(options,UI) { module.exports = function Saturation(options,UI) {
options = options || {};
// Tell UI that a step has been set up
UI.onSetup(options.step);
var output; var output;
function draw(input,callback,progressObj) { function draw(input,callback,progressObj) {
@@ -14,8 +10,6 @@ module.exports = function Saturation(options,UI) {
progressObj.stop(true); progressObj.stop(true);
progressObj.overrideFlag = true; progressObj.overrideFlag = true;
// Tell UI that a step is being drawn
UI.onDraw(options.step);
var step = this; var step = this;
function changePixel(r, g, b, a) { function changePixel(r, g, b, a) {
@@ -39,11 +33,6 @@ module.exports = function Saturation(options,UI) {
// This output is accesible by Image Sequencer // This output is accesible by Image Sequencer
step.output = {src:datauri,format:mimetype}; 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, { return require('../_nomodule/PixelManipulation.js')(input, {

View File

@@ -7,9 +7,9 @@ module.exports = function GetFormat(src) {
var format = undefined; // haha default var format = undefined; // haha default
// EXAMPLE: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAQABADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABykX//Z"; // EXAMPLE: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAQABADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABykX//Z";
// EXAMPLE: "http://example.com/example.png" // EXAMPLE: "http://example.com/example.png"
// EXAMPLE: "/example.png" // EXAMPLE: "/example.png"
if (isDataUrl(src)) { if (isDataUrl(src)) {
format = src.split(';')[0].split('/').pop(); format = src.split(';')[0].split('/').pop();
} else { } else {

View File

@@ -2,16 +2,16 @@ module.exports = {
getPreviousStep : function () { getPreviousStep : function () {
return this.getStep(-1); return this.getStep(-1);
}, },
getNextStep : function() { getNextStep : function() {
return this.getStep(1); return this.getStep(1);
}, },
getInput : function(offset){ getInput : function(offset){
if(offset + this.getIndex() === 0) offset++; if(offset + this.getIndex() === 0) offset++;
return this.getStep(offset - 1).output; return this.getStep(offset - 1).output;
}, },
getOuput : function(offset){ getOuput : function(offset){
return this.getStep(offset).output; return this.getStep(offset).output;
} }