mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-23 00:30:00 +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");
|
console.log('\x1b[31m%s\x1b[0m',"This is the output of the module");
|
||||||
require('./src/ImageSequencerNode');
|
require('./src/ImageSequencer');
|
||||||
sequencer = 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,
|
var image,
|
||||||
steps = [],
|
steps = [],
|
||||||
modules = require('./ModulesNode'),
|
modules = require('./Modules'),
|
||||||
images = {};
|
images = {};
|
||||||
|
|
||||||
// if in browser, prompt for an image
|
// if in browser, prompt for an image
|
||||||
@@ -170,6 +170,24 @@ ImageSequencer = function ImageSequencer(options) {
|
|||||||
run = {};
|
run = {};
|
||||||
this_ = this;
|
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) {
|
if(arguments.length==4 || arguments.length==3) {
|
||||||
o = o || {};
|
o = o || {};
|
||||||
size = this_.images[image].steps.length;
|
size = this_.images[image].steps.length;
|
||||||
@@ -182,13 +200,22 @@ ImageSequencer = function ImageSequencer(options) {
|
|||||||
if (objTypeOf(arguments[0])=='Object') {
|
if (objTypeOf(arguments[0])=='Object') {
|
||||||
for (img in arguments[0]) {
|
for (img in arguments[0]) {
|
||||||
var details = arguments[0][img];
|
var details = arguments[0][img];
|
||||||
if (objTypeOf(details) == "Object")
|
if (objTypeOf(details) == "Object") {
|
||||||
{insertStep(img,details.index,details.name,details.o); run[img]=details.index;}
|
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") {
|
else if (objTypeOf(details) == "Array") {
|
||||||
details = details.sort(function(a,b){return b.index-a.index});
|
details = details.sort(function(a,b){return b.index-a.index});
|
||||||
run[img] = details[details.length-1].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);
|
insertStep(img,details[i].index,details[i].name,details[i].o);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // end if argument is object
|
} // end if argument is object
|
||||||
@@ -198,7 +225,7 @@ ImageSequencer = function ImageSequencer(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function run(t_image,t_from) {
|
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;
|
this_ = this;
|
||||||
runimg = {};
|
runimg = {};
|
||||||
json_q = {};
|
json_q = {};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ var test = require('tape');
|
|||||||
// We should only test headless code here.
|
// We should only test headless code here.
|
||||||
// http://stackoverflow.com/questions/21358015/error-jquery-requires-a-window-with-a-document#25622933
|
// 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" });
|
var sequencer = ImageSequencer({ ui: "none" });
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ test('Image Sequencer has tests', function (t) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('loadImages loads a step', 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.equal(sequencer.images.test.steps.length, 1, "It Does!");
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
@@ -56,4 +56,3 @@ test('run creates output of steps', function (t) {
|
|||||||
t.equal(type,"object");
|
t.equal(type,"object");
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user