mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-13 11:50:02 +01:00
Merge Commit
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
if (typeof window !== 'undefined') {window.$ = window.jQuery = require('jquery'); isBrowser = true}
|
||||
else {window = global; var isBrowser = false}
|
||||
else {var isBrowser = false}
|
||||
|
||||
ImageSequencer = function ImageSequencer(options) {
|
||||
|
||||
@@ -12,7 +12,7 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
return Object.prototype.toString.call(object).split(" ")[1].slice(0,-1)
|
||||
}
|
||||
|
||||
function clog(color,msg) {
|
||||
function log(color,msg) {
|
||||
if(options.ui!="none") {
|
||||
if(arguments.length==1) console.log(arguments[0]);
|
||||
else if(arguments.length==2) console.log(color,msg);
|
||||
@@ -42,27 +42,32 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
steps = [],
|
||||
modules = require('./Modules'),
|
||||
images = {},
|
||||
log = [];
|
||||
inputlog = [];
|
||||
|
||||
// if in browser, prompt for an image
|
||||
// if (options.imageSelect || options.inBrowser) addStep('image-select');
|
||||
// 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,"+");
|
||||
log.push({method:"addSteps", json_q:copy(json_q)});
|
||||
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);
|
||||
}
|
||||
const this_ = (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(this_,args,"+");
|
||||
|
||||
inputlog.push({method:"addSteps", json_q:copy(json_q)});
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
function removeStep(image,index) {
|
||||
//remove the step from images[image].steps and redraw remaining images
|
||||
if(index>0) {
|
||||
clog('\x1b[31m%s\x1b[0m',"Removing "+index+" from "+image);
|
||||
log('\x1b[31m%s\x1b[0m',"Removing "+index+" from "+image);
|
||||
images[image].steps.splice(index,1);
|
||||
}
|
||||
//tell the UI a step has been removed
|
||||
@@ -70,10 +75,12 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
|
||||
function removeSteps(image,index) {
|
||||
run = {};
|
||||
args = [];
|
||||
const 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,"-");
|
||||
log.push({method:"removeSteps", json_q:copy(json_q)});
|
||||
|
||||
json_q = formatInput.call(this_,args,"-");
|
||||
inputlog.push({method:"removeSteps", json_q:copy(json_q)});
|
||||
|
||||
for (img in json_q) {
|
||||
indices = json_q[img].sort(function(a,b){return b-a});
|
||||
@@ -82,77 +89,92 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
removeStep(img,indices[i]);
|
||||
}
|
||||
// this.run(run); // This is creating problems
|
||||
return this;
|
||||
}
|
||||
|
||||
function insertSteps(image, index, name, o) {
|
||||
run = {};
|
||||
this_ = this;
|
||||
args = [];
|
||||
const 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,"^");
|
||||
log.push({method:"insertSteps", json_q:copy(json_q)});
|
||||
json_q = formatInput.call(this_,args,"^");
|
||||
inputlog.push({method:"insertSteps", json_q:copy(json_q)});
|
||||
|
||||
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);
|
||||
// run[img] = details[details.length-1].index;
|
||||
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
|
||||
return this;
|
||||
}
|
||||
|
||||
function run(t_image,t_from) {
|
||||
clog('\x1b[32m%s\x1b[0m',"Running the Sequencer!");
|
||||
this_ = this;
|
||||
args = [];
|
||||
log('\x1b[32m%s\x1b[0m',"Running the Sequencer!");
|
||||
const 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 true;
|
||||
}
|
||||
|
||||
function loadImages() {
|
||||
args = [];
|
||||
for (arg in arguments) args.push(copy(arguments[arg]));
|
||||
json_q = formatInput.call(this,args,"l");
|
||||
json_q_push = copy(json_q);
|
||||
delete json_q_push.callback;
|
||||
log.push({method:"loadImages", json_q:json_q_push});
|
||||
|
||||
inputlog.push({method:"loadImages", json_q:copy(json_q)});
|
||||
loadedimages = this.copy(json_q.loadedimages);
|
||||
|
||||
for (i in json_q.images)
|
||||
require('./LoadImage')(this,i,json_q.images[i])
|
||||
|
||||
if (json_q.callback) json_q.callback();
|
||||
json_q.callback();
|
||||
return {
|
||||
name: "ImageSequencer Wrapper",
|
||||
sequencer: this,
|
||||
addSteps: this.addSteps,
|
||||
removeSteps: this.removeSteps,
|
||||
insertSteps: this.insertSteps,
|
||||
run: this.run,
|
||||
images: loadedimages
|
||||
};
|
||||
}
|
||||
|
||||
function runLog() {
|
||||
for(i in sequencer.log)
|
||||
eval("sequencer."+sequencer.log[i].method).call(sequencer,sequencer.log[i].json_q);
|
||||
return true
|
||||
function replaceImage(selector,steps,options) {
|
||||
options = options || {};
|
||||
return require('./ReplaceImage')(this,selector,steps);
|
||||
}
|
||||
|
||||
return {
|
||||
name: "ImageSequencer",
|
||||
options: options,
|
||||
loadImages: loadImages,
|
||||
loadImage: loadImages,
|
||||
addSteps: addSteps,
|
||||
removeSteps: removeSteps,
|
||||
insertSteps: insertSteps,
|
||||
replaceImage: replaceImage,
|
||||
run: run,
|
||||
log: log,
|
||||
inputlog: inputlog,
|
||||
modules: modules,
|
||||
images: images,
|
||||
ui: options.ui,
|
||||
clog: clog,
|
||||
log: log,
|
||||
objTypeOf: objTypeOf,
|
||||
copy: copy,
|
||||
runLog: runLog
|
||||
copy: copy
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user