mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-15 12:50:04 +01:00
log
This commit is contained in:
4
index.js
4
index.js
@@ -2,10 +2,10 @@ console.log('\x1b[31m%s\x1b[0m',"This is the output of the module");
|
|||||||
require('./src/ImageSequencer');
|
require('./src/ImageSequencer');
|
||||||
sequencer = ImageSequencer();
|
sequencer = ImageSequencer();
|
||||||
sequencer.loadImages({images:{red:'examples/red.jpg'},callback:function(){
|
sequencer.loadImages({images:{red:'examples/red.jpg'},callback:function(){
|
||||||
sequencer.addSteps(['do-nothing-pix','ndvi-red','invert']);
|
sequencer.addSteps(['ndvi-red','do-nothing','do-nothing']);
|
||||||
sequencer.removeSteps(1);
|
sequencer.removeSteps(1);
|
||||||
sequencer.insertSteps({
|
sequencer.insertSteps({
|
||||||
red: [{index: -1, name: 'do-nothing', o:{}}]
|
red: [{index: -1, name: 'do-nothing-pix', o:{}}]
|
||||||
});
|
});
|
||||||
sequencer.run();
|
sequencer.run();
|
||||||
}});
|
}});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
function AddStep(ref, image, name, o) {
|
function AddStep(ref, image, name, o) {
|
||||||
|
|
||||||
function addStep(image, name, o_) {
|
function addStep(image, name, o_) {
|
||||||
ref.log('\x1b[36m%s\x1b[0m','adding step \"' + name + '\" to \"' + image + '\".');
|
ref.clog('\x1b[36m%s\x1b[0m','adding step \"' + name + '\" to \"' + image + '\".');
|
||||||
|
|
||||||
o = {};
|
o = {};
|
||||||
o.id = ref.options.sequencerCounter++; //Gives a Unique ID to each step
|
o.id = ref.options.sequencerCounter++; //Gives a Unique ID to each step
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ ImageSequencer = function ImageSequencer(options) {
|
|||||||
return Object.prototype.toString.call(object).split(" ")[1].slice(0,-1)
|
return Object.prototype.toString.call(object).split(" ")[1].slice(0,-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
function log(color,msg) {
|
function clog(color,msg) {
|
||||||
if(options.ui!="none") {
|
if(options.ui!="none") {
|
||||||
if(arguments.length==1) console.log(arguments[0]);
|
if(arguments.length==1) console.log(arguments[0]);
|
||||||
else if(arguments.length==2) console.log(color,msg);
|
else if(arguments.length==2) console.log(color,msg);
|
||||||
@@ -41,7 +41,8 @@ ImageSequencer = function ImageSequencer(options) {
|
|||||||
var image,
|
var image,
|
||||||
steps = [],
|
steps = [],
|
||||||
modules = require('./Modules'),
|
modules = require('./Modules'),
|
||||||
images = {};
|
images = {},
|
||||||
|
log = [];
|
||||||
|
|
||||||
// if in browser, prompt for an image
|
// if in browser, prompt for an image
|
||||||
// if (options.imageSelect || options.inBrowser) addStep('image-select');
|
// if (options.imageSelect || options.inBrowser) addStep('image-select');
|
||||||
@@ -52,6 +53,7 @@ ImageSequencer = function ImageSequencer(options) {
|
|||||||
json_q = {};
|
json_q = {};
|
||||||
for(arg in arguments){args.push(copy(arguments[arg]));}
|
for(arg in arguments){args.push(copy(arguments[arg]));}
|
||||||
json_q = formatInput.call(this,args,"+");
|
json_q = formatInput.call(this,args,"+");
|
||||||
|
log.push({method:"addSteps", json_q:copy(json_q)});
|
||||||
for (i in json_q)
|
for (i in json_q)
|
||||||
for (j in json_q[i])
|
for (j in json_q[i])
|
||||||
require("./AddStep")(this,i,json_q[i][j].name,json_q[i][j].o);
|
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) {
|
function removeStep(image,index) {
|
||||||
//remove the step from images[image].steps and redraw remaining images
|
//remove the step from images[image].steps and redraw remaining images
|
||||||
if(index>0) {
|
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);
|
images[image].steps.splice(index,1);
|
||||||
}
|
}
|
||||||
//tell the UI a step has been removed
|
//tell the UI a step has been removed
|
||||||
@@ -71,6 +73,7 @@ ImageSequencer = function ImageSequencer(options) {
|
|||||||
args = [];
|
args = [];
|
||||||
for(arg in arguments) args.push(copy(arguments[arg]));
|
for(arg in arguments) args.push(copy(arguments[arg]));
|
||||||
json_q = formatInput.call(this,args,"-");
|
json_q = formatInput.call(this,args,"-");
|
||||||
|
log.push({method:"removeSteps", json_q:copy(json_q)});
|
||||||
|
|
||||||
for (img in json_q) {
|
for (img in json_q) {
|
||||||
indices = json_q[img].sort(function(a,b){return b-a});
|
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]);
|
for (arg in arguments) args.push(arguments[arg]);
|
||||||
|
|
||||||
json_q = formatInput.call(this,args,"^");
|
json_q = formatInput.call(this,args,"^");
|
||||||
|
log.push({method:"insertSteps", json_q:copy(json_q)});
|
||||||
|
|
||||||
for (img in json_q) {
|
for (img in json_q) {
|
||||||
var details = json_q[img];
|
var details = json_q[img];
|
||||||
@@ -100,7 +104,7 @@ ImageSequencer = function ImageSequencer(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function run(t_image,t_from) {
|
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;
|
this_ = this;
|
||||||
args = [];
|
args = [];
|
||||||
for (var arg in arguments) args.push(copy(arguments[arg]));
|
for (var arg in arguments) args.push(copy(arguments[arg]));
|
||||||
@@ -118,11 +122,20 @@ ImageSequencer = function ImageSequencer(options) {
|
|||||||
args = [];
|
args = [];
|
||||||
for (arg in arguments) args.push(copy(arguments[arg]));
|
for (arg in arguments) args.push(copy(arguments[arg]));
|
||||||
json_q = formatInput.call(this,args,"l");
|
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)
|
for (i in json_q.images)
|
||||||
require('./LoadImage')(this,i,json_q.images[i])
|
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 {
|
return {
|
||||||
@@ -132,12 +145,14 @@ ImageSequencer = function ImageSequencer(options) {
|
|||||||
removeSteps: removeSteps,
|
removeSteps: removeSteps,
|
||||||
insertSteps: insertSteps,
|
insertSteps: insertSteps,
|
||||||
run: run,
|
run: run,
|
||||||
|
log: log,
|
||||||
modules: modules,
|
modules: modules,
|
||||||
images: images,
|
images: images,
|
||||||
ui: options.ui,
|
ui: options.ui,
|
||||||
log: log,
|
clog: clog,
|
||||||
objTypeOf: objTypeOf,
|
objTypeOf: objTypeOf,
|
||||||
copy: copy
|
copy: copy,
|
||||||
|
runLog: runLog
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
function InsertStep(ref, image, index, name, o) {
|
function InsertStep(ref, image, index, name, o) {
|
||||||
|
|
||||||
function insertStep(image, index, name, o) {
|
function insertStep(image, index, name, o) {
|
||||||
ref.log('\x1b[36m%s\x1b[0m','inserting step \"' + name + '\" to \"' + image + '\" at \"'+index+'\".');
|
ref.clog('\x1b[36m%s\x1b[0m','inserting step \"' + name + '\" to \"' + image + '\" at \"'+index+'\".');
|
||||||
|
|
||||||
o = o || {};
|
o = o || {};
|
||||||
o.id = ref.options.sequencerCounter++; //Gives a Unique ID to each step
|
o.id = ref.options.sequencerCounter++; //Gives a Unique ID to each step
|
||||||
|
|||||||
Reference in New Issue
Block a user