From aba3ba1392bec8132082cbb9b0b8c8e9864c07c2 Mon Sep 17 00:00:00 2001 From: Chinmay Pandhare Date: Mon, 13 Mar 2017 20:17:23 +0530 Subject: [PATCH] Completed the addStep issue. --- dist/image-sequencer.js | 23 +++++++++++++++++++++++ index.html | 2 +- src/ImageSequencer.js | 22 ++++++++++++++++++++++ src/modules/ImageSelect.js | 1 + 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/dist/image-sequencer.js b/dist/image-sequencer.js index da8ea2bb..dc4fcfa6 100644 --- a/dist/image-sequencer.js +++ b/dist/image-sequencer.js @@ -184159,6 +184159,25 @@ ImageSequencer = function ImageSequencer(options) { // if in browser, prompt for an image if (options.imageSelect || options.inBrowser) addStep('image-select'); + // { + // console.log('adding step "image-select"'); + // o = {}; + // o.name = 'image-select'; + // o.selector = 'ismod-image-select'; + // o.container = o.container || options.selector; + // + // var module = modules['image-select'](o); + // + // steps.push(module); + // + // module.setup(); + // + // // Pre-set the initial output behavior of the final step, + // // which will be changed if an additional step is added. + // module.options.output = function output(image) { + // if (module.options.ui && module.options.ui.display) module.options.ui.display(image); + // } + // } else if (options.imageUrl) loadImage(imageUrl); // soon, detect local or URL? @@ -184198,6 +184217,9 @@ ImageSequencer = function ImageSequencer(options) { if (previousStep) { // connect output of last step to input of this step previousStep.options.output = function output(image) { + if (sequencer.steps[0].options.initial_image) { + options.initial_image = sequencer.steps[0].options.initial_image; + } log('running module "' + name + '"'); // display the image in any available ui if (previousStep.options.ui && previousStep.options.ui.display) previousStep.options.ui.display(image); @@ -184409,6 +184431,7 @@ module.exports = function ImageSelect(options) { // this module is unique because it creates the image function draw(image) { el.html(image); + options.initial_image = image; if (options.output) options.output(image); } diff --git a/index.html b/index.html index 69e26e43..99e01aca 100644 --- a/index.html +++ b/index.html @@ -74,7 +74,7 @@ $('.add-step').click(function(e) { e.preventDefault(); sequencer.addStep($('.select-module').val()); - sequencer.run(sequencer.initial_image); // later we might only run this step, if we can fetch the image output from the previous + sequencer.run(sequencer.options.initial_image); // later we might only run this step, if we can fetch the image output from the previous }); diff --git a/src/ImageSequencer.js b/src/ImageSequencer.js index c366a13c..2048c9b0 100644 --- a/src/ImageSequencer.js +++ b/src/ImageSequencer.js @@ -13,6 +13,25 @@ ImageSequencer = function ImageSequencer(options) { // if in browser, prompt for an image if (options.imageSelect || options.inBrowser) addStep('image-select'); + // { + // console.log('adding step "image-select"'); + // o = {}; + // o.name = 'image-select'; + // o.selector = 'ismod-image-select'; + // o.container = o.container || options.selector; + // + // var module = modules['image-select'](o); + // + // steps.push(module); + // + // module.setup(); + // + // // Pre-set the initial output behavior of the final step, + // // which will be changed if an additional step is added. + // module.options.output = function output(image) { + // if (module.options.ui && module.options.ui.display) module.options.ui.display(image); + // } + // } else if (options.imageUrl) loadImage(imageUrl); // soon, detect local or URL? @@ -52,6 +71,9 @@ ImageSequencer = function ImageSequencer(options) { if (previousStep) { // connect output of last step to input of this step previousStep.options.output = function output(image) { + if (sequencer.steps[0].options.initial_image) { + options.initial_image = sequencer.steps[0].options.initial_image; + } log('running module "' + name + '"'); // display the image in any available ui if (previousStep.options.ui && previousStep.options.ui.display) previousStep.options.ui.display(image); diff --git a/src/modules/ImageSelect.js b/src/modules/ImageSelect.js index 4285e882..66bed966 100644 --- a/src/modules/ImageSelect.js +++ b/src/modules/ImageSelect.js @@ -68,6 +68,7 @@ module.exports = function ImageSelect(options) { // this module is unique because it creates the image function draw(image) { el.html(image); + options.initial_image = image; if (options.output) options.output(image); }