mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-14 04:10:04 +01:00
log
This commit is contained in:
@@ -12,7 +12,7 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
return Object.prototype.toString.call(object).split(" ")[1].slice(0,-1)
|
||||
}
|
||||
|
||||
function log(color,msg) {
|
||||
function clog(color,msg) {
|
||||
if(options.ui!="none") {
|
||||
if(arguments.length==1) console.log(arguments[0]);
|
||||
else if(arguments.length==2) console.log(color,msg);
|
||||
@@ -41,7 +41,8 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
var image,
|
||||
steps = [],
|
||||
modules = require('./Modules'),
|
||||
images = {};
|
||||
images = {},
|
||||
log = [];
|
||||
|
||||
// if in browser, prompt for an image
|
||||
// if (options.imageSelect || options.inBrowser) addStep('image-select');
|
||||
@@ -52,6 +53,7 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
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);
|
||||
@@ -60,7 +62,7 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
function removeStep(image,index) {
|
||||
//remove the step from images[image].steps and redraw remaining images
|
||||
if(index>0) {
|
||||
log('\x1b[31m%s\x1b[0m',"Removing "+index+" from "+image);
|
||||
clog('\x1b[31m%s\x1b[0m',"Removing "+index+" from "+image);
|
||||
images[image].steps.splice(index,1);
|
||||
}
|
||||
//tell the UI a step has been removed
|
||||
@@ -71,6 +73,7 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
args = [];
|
||||
for(arg in arguments) args.push(copy(arguments[arg]));
|
||||
json_q = formatInput.call(this,args,"-");
|
||||
log.push({method:"removeSteps", json_q:copy(json_q)});
|
||||
|
||||
for (img in json_q) {
|
||||
indices = json_q[img].sort(function(a,b){return b-a});
|
||||
@@ -88,6 +91,7 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
for (arg in arguments) args.push(arguments[arg]);
|
||||
|
||||
json_q = formatInput.call(this,args,"^");
|
||||
log.push({method:"insertSteps", json_q:copy(json_q)});
|
||||
|
||||
for (img in json_q) {
|
||||
var details = json_q[img];
|
||||
@@ -100,7 +104,7 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
}
|
||||
|
||||
function run(t_image,t_from) {
|
||||
log('\x1b[32m%s\x1b[0m',"Running the Sequencer!");
|
||||
clog('\x1b[32m%s\x1b[0m',"Running the Sequencer!");
|
||||
this_ = this;
|
||||
args = [];
|
||||
for (var arg in arguments) args.push(copy(arguments[arg]));
|
||||
@@ -118,11 +122,20 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
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});
|
||||
|
||||
for (i in json_q.images)
|
||||
require('./LoadImage')(this,i,json_q.images[i])
|
||||
|
||||
json_q.callback();
|
||||
if (json_q.callback) json_q.callback();
|
||||
}
|
||||
|
||||
function runLog() {
|
||||
for(i in sequencer.log)
|
||||
eval("sequencer."+sequencer.log[i].method).call(sequencer,sequencer.log[i].json_q);
|
||||
return true
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -132,12 +145,14 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
removeSteps: removeSteps,
|
||||
insertSteps: insertSteps,
|
||||
run: run,
|
||||
log: log,
|
||||
modules: modules,
|
||||
images: images,
|
||||
ui: options.ui,
|
||||
log: log,
|
||||
clog: clog,
|
||||
objTypeOf: objTypeOf,
|
||||
copy: copy
|
||||
copy: copy,
|
||||
runLog: runLog
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user