mirror of
https://github.com/publiclab/image-sequencer.git
synced 2026-06-16 04:33:26 +02:00
Opaque meta module + test - colorbar (#764)
* opaque colorbar test * build * rebase + build * fixed opaque meta modules yay Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * add test and prevent internal logs Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * Update meta-modules.js
This commit is contained in:
committed by
Jeffrey Warren
parent
53db6bd2ce
commit
fa30c1b30f
Vendored
+4842
-4818
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -6,7 +6,7 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
|
||||
var sequencer = (this.name == "ImageSequencer") ? this : this.sequencer;
|
||||
options = options || {};
|
||||
options.inBrowser = options.inBrowser || isBrowser;
|
||||
options.inBrowser = options.inBrowser === undefined ? isBrowser : options.inBrowser;
|
||||
options.sequencerCounter = 0;
|
||||
|
||||
function objTypeOf(object) {
|
||||
|
||||
@@ -1,18 +1,41 @@
|
||||
module.exports = function NdviColormapfunction(options, UI) {
|
||||
module.exports = function Colorbar(options, UI) {
|
||||
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
var output;
|
||||
|
||||
options.x = options.x || defaults.x;
|
||||
options.y = options.y || defaults.y;
|
||||
options.colormap = options.colormap || defaults.colormap;
|
||||
options.h = options.h || defaults.h;
|
||||
this.expandSteps([
|
||||
{ 'name': 'gradient', 'options': {} },
|
||||
{ 'name': 'colormap', 'options': { colormap: options.colormap } },
|
||||
{ 'name': 'crop', 'options': { 'y': 0, 'h': options.h } },
|
||||
{ 'name': 'overlay', 'options': { 'x': options.x, 'y': options.y, 'offset': -4 } }
|
||||
]);
|
||||
return {
|
||||
isMeta: true
|
||||
}
|
||||
}
|
||||
options.x = options.x || defaults.x;
|
||||
options.y = options.y || defaults.y;
|
||||
options.colormap = options.colormap || defaults.colormap;
|
||||
options.h = options.h || defaults.h;
|
||||
|
||||
var steps = [
|
||||
{ 'name': 'gradient', 'options': {} },
|
||||
{ 'name': 'colormap', 'options': { colormap: options.colormap } },
|
||||
{ 'name': 'crop', 'options': { 'y': 0, 'h': options.h } },
|
||||
{ 'name': 'overlay', 'options': { 'x': options.x, 'y': options.y, 'offset': -4 } }
|
||||
];
|
||||
|
||||
// ui: false prevents internal logs
|
||||
var internalSequencer = ImageSequencer({ inBrowser: false, ui: false });
|
||||
|
||||
function draw(input, callback) {
|
||||
|
||||
var step = this;
|
||||
|
||||
internalSequencer.loadImage(input.src, function onAddImage() {
|
||||
internalSequencer.importJSON(steps);
|
||||
internalSequencer.run(function onCallback(internalOutput) {
|
||||
step.output = { src: internalOutput, format: input.format };
|
||||
callback();
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
options: options,
|
||||
draw: draw,
|
||||
output: output,
|
||||
UI: UI
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,5 @@
|
||||
"default": 10
|
||||
}
|
||||
},
|
||||
"length": 4,
|
||||
"docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
|
||||
"docs-link": "https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
|
||||
}
|
||||
@@ -13,4 +13,13 @@ test('Load ndvi-colormap meta module', function(t) {
|
||||
t.equal(sequencer1.images.image1.steps[0].options.name, sequencer2.steps[0].options.name, "First step OK");
|
||||
t.equal(sequencer1.images.image1.steps[1].options.name, sequencer2.steps[1].options.name, "Second step OK");
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('Load colorbar opaque meta module', function(t) {
|
||||
sequencer1.loadImages('image1', red);
|
||||
sequencer1.addSteps('colorbar'); // this has been refactored as an opaque meta-module https://github.com/publiclab/image-sequencer/issues/315
|
||||
sequencer1.run((out) => {
|
||||
t.isNotEqual(out, undefined, "Opaque Meta-Module not undefined");
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user