From 782e60269e7d36e15cfff55a7e6b7b622e55187d Mon Sep 17 00:00:00 2001 From: Chinmay Pandhare Date: Tue, 15 Aug 2017 14:27:38 +0530 Subject: [PATCH] options accessible via step, implemented options in demo --- dist/image-sequencer.js | 43 ++++++++++++++++++++++----------- examples/index.html | 23 ++++++++++++++++-- src/AddStep.js | 3 ++- src/InsertStep.js | 3 ++- src/modules/Crop/Crop.js | 13 +++++++--- src/modules/FisheyeGl/Module.js | 22 +++++++++++------ src/modules/FisheyeGl/info.json | 2 +- 7 files changed, 79 insertions(+), 30 deletions(-) diff --git a/dist/image-sequencer.js b/dist/image-sequencer.js index 0994fcec..f80cf9b5 100644 --- a/dist/image-sequencer.js +++ b/dist/image-sequencer.js @@ -27866,7 +27866,8 @@ function AddStep(ref, image, name, o) { ID: o.number, imageName: o.image, inBrowser: ref.options.inBrowser, - ui: ref.options.ui + ui: ref.options.ui, + options: o }; var UI = ref.events; var module = ref.modules[name][0](o,UI); @@ -28341,7 +28342,8 @@ function InsertStep(ref, image, index, name, o) { ID: o.number, imageName: o.image, inBrowser: ref.options.inBrowser, - ui: ref.options.ui + ui: ref.options.ui, + options: o }; var UI = ref.events; var module = ref.modules[name][0](o,UI); @@ -28653,11 +28655,16 @@ module.exports = function Crop(input,options,callback) { var getPixels = require('get-pixels'), savePixels = require('save-pixels'); + options.x = parseInt(options.x) || 0; + options.y = parseInt(options.y) || 0; + getPixels(input.src,function(err,pixels){ - var ox = parseInt(options.x) || 0; - var oy = parseInt(options.y) || 0; - var w = parseInt(options.w) || Math.floor(0.5*pixels.shape[0]); - var h = parseInt(options.h) || Math.floor(0.5*pixels.shape[1]); + options.w = parseInt(options.w) || Math.floor(0.5*pixels.shape[0]); + options.h = parseInt(options.h) || Math.floor(0.5*pixels.shape[1]); + var ox = options.x; + var oy = options.y; + var w = options.w; + var h = options.h; var iw = pixels.shape[0]; //Width of Original Image var newarray = new Uint8Array(4*w*h); for (var n = oy; n < oy + h; n++) { @@ -28922,13 +28929,21 @@ module.exports = function DoNothing(options,UI) { selector: "#image-sequencer-canvas" }); - distorter.lens.a = parseFloat(options.a) || distorter.lens.a; - distorter.lens.b = parseFloat(options.b) || distorter.lens.b; - distorter.lens.Fx = parseFloat(options.Fx) || distorter.lens.Fx; - distorter.lens.Fy = parseFloat(options.Fy) || distorter.lens.Fy; - distorter.lens.scale = parseFloat(options.scale) || distorter.lens.scale; - distorter.fov.x = parseFloat(options.x) || distorter.fov.x; - distorter.fov.y = parseFloat(options.y) || distorter.fov.y; + options.a = parseFloat(options.a) || distorter.lens.a; + options.b = parseFloat(options.b) || distorter.lens.b; + options.Fx = parseFloat(options.Fx) || distorter.lens.Fx; + options.Fy = parseFloat(options.Fy) || distorter.lens.Fy; + options.scale = parseFloat(options.scale) || distorter.lens.scale; + options.x = parseFloat(options.x) || distorter.fov.x; + options.y = parseFloat(options.y) || distorter.fov.y; + + distorter.lens.a = options.a; + distorter.lens.b = options.b; + distorter.lens.Fx = options.Fx; + distorter.lens.Fy = options.Fy; + distorter.lens.scale = options.scale; + distorter.fov.x = options.x; + distorter.fov.y = options.y; distorter.setImage(input.src,function(){ step.output = {src: canvas.toDataURL(), format: input.format}; @@ -28973,7 +28988,7 @@ module.exports={ "min": 0, "max": 4 }, - "Fx": { + "Fy": { "type": "float", "desc": "Fy parameter", "default": 0, diff --git a/examples/index.html b/examples/index.html index e84c9b07..27b0ac3b 100644 --- a/examples/index.html +++ b/examples/index.html @@ -96,8 +96,6 @@ \
\

'+step.name+'

\ -
Width: x
\ -
Height: y
\
\ \ '; @@ -109,6 +107,17 @@ step.ui = step.ui.querySelector('div.r'); step.imgElement = step.ui.querySelector('img'); + if(sequencer.modulesInfo().hasOwnProperty(step.name)) { + var inputs = sequencer.modulesInfo(step.name).inputs; + for (var i in inputs) { + var div = document.createElement('div'); + div.className = "r nomargin"; + div.setAttribute('name',i); + div.innerHTML = i + ": " + ""; + step.ui.querySelector('div.details').appendChild(div); + } + } + if(step.name != "load-image") step.ui.querySelector('div.details').appendChild( parser.parseFromString(removebutton,'text/html') @@ -119,7 +128,17 @@ }, onComplete: function(step) { + step.imgElement.src = step.output; + + if(sequencer.modulesInfo().hasOwnProperty(step.name)) { + var inputs = sequencer.modulesInfo(step.name).inputs; + for (var i in inputs) { + step.ui.querySelector('div[name="'+i+'"] span') + .innerHTML = step.options[i]; + } + } + }, onRemove: function(step) { diff --git a/src/AddStep.js b/src/AddStep.js index 9eeb7181..53792b40 100644 --- a/src/AddStep.js +++ b/src/AddStep.js @@ -14,7 +14,8 @@ function AddStep(ref, image, name, o) { ID: o.number, imageName: o.image, inBrowser: ref.options.inBrowser, - ui: ref.options.ui + ui: ref.options.ui, + options: o }; var UI = ref.events; var module = ref.modules[name][0](o,UI); diff --git a/src/InsertStep.js b/src/InsertStep.js index d10b27fc..c45a0eff 100644 --- a/src/InsertStep.js +++ b/src/InsertStep.js @@ -15,7 +15,8 @@ function InsertStep(ref, image, index, name, o) { ID: o.number, imageName: o.image, inBrowser: ref.options.inBrowser, - ui: ref.options.ui + ui: ref.options.ui, + options: o }; var UI = ref.events; var module = ref.modules[name][0](o,UI); diff --git a/src/modules/Crop/Crop.js b/src/modules/Crop/Crop.js index 0f9932b8..3952815a 100644 --- a/src/modules/Crop/Crop.js +++ b/src/modules/Crop/Crop.js @@ -3,11 +3,16 @@ module.exports = function Crop(input,options,callback) { var getPixels = require('get-pixels'), savePixels = require('save-pixels'); + options.x = parseInt(options.x) || 0; + options.y = parseInt(options.y) || 0; + getPixels(input.src,function(err,pixels){ - var ox = parseInt(options.x) || 0; - var oy = parseInt(options.y) || 0; - var w = parseInt(options.w) || Math.floor(0.5*pixels.shape[0]); - var h = parseInt(options.h) || Math.floor(0.5*pixels.shape[1]); + options.w = parseInt(options.w) || Math.floor(0.5*pixels.shape[0]); + options.h = parseInt(options.h) || Math.floor(0.5*pixels.shape[1]); + var ox = options.x; + var oy = options.y; + var w = options.w; + var h = options.h; var iw = pixels.shape[0]; //Width of Original Image var newarray = new Uint8Array(4*w*h); for (var n = oy; n < oy + h; n++) { diff --git a/src/modules/FisheyeGl/Module.js b/src/modules/FisheyeGl/Module.js index a636b28f..ddb72a11 100644 --- a/src/modules/FisheyeGl/Module.js +++ b/src/modules/FisheyeGl/Module.js @@ -28,13 +28,21 @@ module.exports = function DoNothing(options,UI) { selector: "#image-sequencer-canvas" }); - distorter.lens.a = parseFloat(options.a) || distorter.lens.a; - distorter.lens.b = parseFloat(options.b) || distorter.lens.b; - distorter.lens.Fx = parseFloat(options.Fx) || distorter.lens.Fx; - distorter.lens.Fy = parseFloat(options.Fy) || distorter.lens.Fy; - distorter.lens.scale = parseFloat(options.scale) || distorter.lens.scale; - distorter.fov.x = parseFloat(options.x) || distorter.fov.x; - distorter.fov.y = parseFloat(options.y) || distorter.fov.y; + options.a = parseFloat(options.a) || distorter.lens.a; + options.b = parseFloat(options.b) || distorter.lens.b; + options.Fx = parseFloat(options.Fx) || distorter.lens.Fx; + options.Fy = parseFloat(options.Fy) || distorter.lens.Fy; + options.scale = parseFloat(options.scale) || distorter.lens.scale; + options.x = parseFloat(options.x) || distorter.fov.x; + options.y = parseFloat(options.y) || distorter.fov.y; + + distorter.lens.a = options.a; + distorter.lens.b = options.b; + distorter.lens.Fx = options.Fx; + distorter.lens.Fy = options.Fy; + distorter.lens.scale = options.scale; + distorter.fov.x = options.x; + distorter.fov.y = options.y; distorter.setImage(input.src,function(){ step.output = {src: canvas.toDataURL(), format: input.format}; diff --git a/src/modules/FisheyeGl/info.json b/src/modules/FisheyeGl/info.json index b2230dc3..2788caae 100644 --- a/src/modules/FisheyeGl/info.json +++ b/src/modules/FisheyeGl/info.json @@ -22,7 +22,7 @@ "min": 0, "max": 4 }, - "Fx": { + "Fy": { "type": "float", "desc": "Fy parameter", "default": 0,