Domain for Chaining

This commit is contained in:
Chinmay Pandhare
2017-07-10 18:36:34 +05:30
parent 297f1daaad
commit 1bc3ce2ecc
5 changed files with 108 additions and 48 deletions

View File

@@ -48,15 +48,18 @@ ImageSequencer = function ImageSequencer(options) {
// else if (options.imageUrl) loadImage(imageUrl);
function addSteps(){
args = [];
json_q = {};
for(arg in arguments){args.push(copy(arguments[arg]));}
json_q = formatInput.call(this,args,"+");
for (i in json_q)
for (j in json_q[i])
require("./AddStep")(this,i,json_q[i][j].name,json_q[i][j].o);
return this;
}
thiss = (this.name == "ImageSequencer")?this:this.sequencer;
args = (this.name == "ImageSequencer")?[]:[this.images];
json_q = {};
for(arg in arguments){args.push(copy(arguments[arg]));}
json_q = formatInput.call(thiss,args,"+");
for (i in json_q)
for (j in json_q[i])
require("./AddStep")(thiss,i,json_q[i][j].name,json_q[i][j].o);
return this;
}
function removeStep(image,index) {
//remove the step from images[image].steps and redraw remaining images
@@ -69,9 +72,10 @@ ImageSequencer = function ImageSequencer(options) {
function removeSteps(image,index) {
run = {};
args = [];
this_ = (this.name == "ImageSequencer")?this:this.sequencer;
args = (this.name == "ImageSequencer")?[]:[this.images];
for(arg in arguments) args.push(copy(arguments[arg]));
json_q = formatInput.call(this,args,"-");
json_q = formatInput.call(this_,args,"-");
for (img in json_q) {
indices = json_q[img].sort(function(a,b){return b-a});
@@ -85,17 +89,17 @@ ImageSequencer = function ImageSequencer(options) {
function insertSteps(image, index, name, o) {
run = {};
this_ = this;
args = [];
this_ = (this.name == "ImageSequencer")?this:this.sequencer;
args = (this.name == "ImageSequencer")?[]:[this.images];
for (arg in arguments) args.push(arguments[arg]);
json_q = formatInput.call(this,args,"^");
json_q = formatInput.call(this_,args,"^");
for (img in json_q) {
var details = json_q[img];
details = details.sort(function(a,b){return b.index-a.index});
for (i in details)
require("./InsertStep")(this,img,details[i].index,details[i].name,details[i].o);
require("./InsertStep")(this_,img,details[i].index,details[i].name,details[i].o);
run[img] = details[details.length-1].index;
}
// this.run(run); // This is Creating issues
@@ -104,19 +108,19 @@ ImageSequencer = function ImageSequencer(options) {
function run(t_image,t_from) {
log('\x1b[32m%s\x1b[0m',"Running the Sequencer!");
this_ = this;
args = [];
this_ = (this.name == "ImageSequencer")?this:this.sequencer;
args = (this.name == "ImageSequencer")?[]:[this.images];
for (var arg in arguments) args.push(copy(arguments[arg]));
callback = function() {};
for (var arg in args)
if(objTypeOf(args[arg]) == "Function")
callback = args.splice(arg,1)[0];
json_q = formatInput.call(this,args,"r");
json_q = formatInput.call(this_,args,"r");
require('./Run')(this, json_q, callback);
require('./Run')(this_, json_q, callback);
return this;
return true;
}
function loadImages() {
@@ -124,11 +128,21 @@ ImageSequencer = function ImageSequencer(options) {
for (arg in arguments) args.push(copy(arguments[arg]));
json_q = formatInput.call(this,args,"l");
loadedimages = this.copy(json_q.loadedimages);
for (i in json_q.images)
require('./LoadImage')(this,i,json_q.images[i])
json_q.callback();
return this;
return {
name: "ImageSequencer Wrapper",
sequencer: this,
addSteps: this.addSteps,
removeSteps: this.removeSteps,
insertSteps: this.insertSteps,
run: this.run,
images: loadedimages
};
}
function replaceImage(selector,steps,options) {
@@ -137,6 +151,7 @@ ImageSequencer = function ImageSequencer(options) {
}
return {
name: "ImageSequencer",
options: options,
loadImages: loadImages,
loadImage: loadImages,