mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-23 08:40:03 +01:00
Phase 1 Completion
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 351 KiB |
BIN
examples/red.jpg
Normal file
BIN
examples/red.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 288 B |
10
index.js
10
index.js
@@ -1,4 +1,10 @@
|
||||
console.log('\x1b[31m%s\x1b[0m',"This is the output of the module");
|
||||
require('./src/ImageSequencerNode');
|
||||
require('./src/ImageSequencer');
|
||||
sequencer = ImageSequencer();
|
||||
sequencer.loadImages({red:'../../red.jpg'});
|
||||
sequencer.loadImages({red:'examples/red.jpg'},function(){
|
||||
sequencer.addSteps(['do-nothing','do-nothing-pix','do-nothing']);
|
||||
sequencer.run();
|
||||
sequencer.removeSteps(1);
|
||||
sequencer.insertSteps(1,'do-nothing');
|
||||
sequencer.insertSteps(-1,'do-nothing');
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
|
||||
var image,
|
||||
steps = [],
|
||||
modules = require('./ModulesNode'),
|
||||
modules = require('./Modules'),
|
||||
images = {};
|
||||
|
||||
// if in browser, prompt for an image
|
||||
@@ -170,6 +170,24 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
run = {};
|
||||
this_ = this;
|
||||
|
||||
if (arguments.length==2 || arguments.length==3) {
|
||||
if (typeof(arguments[0])=="number") {
|
||||
if (typeof(arguments[1])=="string" || objTypeOf(arguments[1])=="Array") {
|
||||
var p = arguments[0];
|
||||
var m = arguments[1];
|
||||
var o = arguments[2];
|
||||
arguments = [];
|
||||
arguments[0] = {};
|
||||
for (image in this_.images) {
|
||||
arguments[0][image] = {
|
||||
index: p,
|
||||
name: m,
|
||||
o: o
|
||||
};
|
||||
}
|
||||
}
|
||||
} // end if argument is string
|
||||
}
|
||||
if(arguments.length==4 || arguments.length==3) {
|
||||
o = o || {};
|
||||
size = this_.images[image].steps.length;
|
||||
@@ -182,15 +200,24 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
if (objTypeOf(arguments[0])=='Object') {
|
||||
for (img in arguments[0]) {
|
||||
var details = arguments[0][img];
|
||||
if (objTypeOf(details) == "Object")
|
||||
{insertStep(img,details.index,details.name,details.o); run[img]=details.index;}
|
||||
if (objTypeOf(details) == "Object") {
|
||||
size = this_.images[img].steps.length;
|
||||
details.index = (details.index==size)?details.index:details.index%size;
|
||||
if (details.index<0) details.index += size+1;
|
||||
insertStep(img,details.index,details.name,details.o);
|
||||
run[img]=details.index;
|
||||
}
|
||||
else if (objTypeOf(details) == "Array") {
|
||||
details = details.sort(function(a,b){return b.index-a.index});
|
||||
run[img] = details[details.length-1].index;
|
||||
for (i in details)
|
||||
for (i in details) {
|
||||
size = this_.images[img].steps.length;
|
||||
details[i].index = (details[i].index==size)?details[i].index:details[i].index%size;
|
||||
if (details[i].index<0) details[i].index += size+1;
|
||||
insertStep(img,details[i].index,details[i].name,details[i].o);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end if argument is object
|
||||
}
|
||||
|
||||
@@ -198,7 +225,7 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
}
|
||||
|
||||
function run(t_image,t_from) {
|
||||
log('\x1b[31m%s\x1b[0m',"Running the Sequencer!");
|
||||
log('\x1b[32m%s\x1b[0m',"Running the Sequencer!");
|
||||
this_ = this;
|
||||
runimg = {};
|
||||
json_q = {};
|
||||
|
||||
@@ -6,7 +6,7 @@ var test = require('tape');
|
||||
// We should only test headless code here.
|
||||
// http://stackoverflow.com/questions/21358015/error-jquery-requires-a-window-with-a-document#25622933
|
||||
|
||||
require('../src/ImageSequencerNode.js');
|
||||
require('../src/ImageSequencer.js');
|
||||
|
||||
var sequencer = ImageSequencer({ ui: "none" });
|
||||
|
||||
@@ -24,7 +24,7 @@ test('Image Sequencer has tests', function (t) {
|
||||
});
|
||||
|
||||
test('loadImages loads a step', function (t){
|
||||
sequencer.loadImages('test','examples/SundarPichai.jpeg');
|
||||
sequencer.loadImages('test','examples/red.jpg');
|
||||
t.equal(sequencer.images.test.steps.length, 1, "It Does!");
|
||||
t.end();
|
||||
});
|
||||
@@ -56,4 +56,3 @@ test('run creates output of steps', function (t) {
|
||||
t.equal(type,"object");
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user