Updated Readme, bugfixes

This commit is contained in:
Chinmay Pandhare
2017-06-16 21:27:40 +05:30
parent 1b67d52a96
commit f13da0fb19
4 changed files with 24 additions and 12 deletions

View File

@@ -96,6 +96,23 @@ sequencer.removeSteps({
});
```
Steps can be inserted using the `insertSteps` method. It accepts `image`, `index`, `module_name` and `optional_options` as parameters. `image` may be an array. `optional_options` is an object. The rest are literals. JSON Input is supported too. If no image is provided, Steps will be inserted on all images. Indexes can be negative. Negative sign with an index means that counting will be done in reverse order. If the index is out of bounds, the counting will wrap in the original direction of counting.
```js
sequencer.insertSteps("image",index,"module_name",o);
```
```js
sequencer.insertSteps([image],index,"module_name",o);
```
```js
sequencer.insertSteps({
image1: [
{index:index1, name: module_name1, o:optional_options1},
{index:index2, name: module_name2, o:optional_options2},
...
]
});
```
## Contributing

View File

@@ -2,10 +2,10 @@ console.log('\x1b[31m%s\x1b[0m',"This is the output of the module");
require('./src/ImageSequencer');
sequencer = ImageSequencer();
sequencer.loadImages({red:'examples/red.jpg'},function(){
sequencer.addSteps(['do-nothing','do-nothing-pix','do-nothing','do-nothing']);
sequencer.addSteps(['do-nothing','do-nothing-pix','do-nothing','do-nothing']);
sequencer.addSteps(['do-nothing','do-nothing','do-nothing']);
sequencer.run();
sequencer.removeSteps(1);
sequencer.insertSteps(1,'do-nothing');
sequencer.insertSteps(-1,'do-nothing');
sequencer.insertSteps({
red: [{index: -1, name: 'do-nothing', o:{}}]
});
});

File diff suppressed because one or more lines are too long

View File

@@ -226,21 +226,17 @@ ImageSequencer = function ImageSequencer(options) {
for (img in arguments[0]) {
var details = arguments[0][img];
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;
details = makeArray(details);
}
else if (objTypeOf(details) == "Array") {
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) {
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);
}
run[img] = details[details.length-1].index;
}
}
} // end if argument is object