mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-11 19:00:00 +01:00
createMetaModule generator (#779)
* initial createMetaModule * fixes * fix * Update createMetaModule.js * Update createMetaModule.js * refactor and fix Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * update ndvi-colormap Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * fix test Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * add docs Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
This commit is contained in:
@@ -1,41 +1,14 @@
|
||||
module.exports = function Colorbar(options, UI) {
|
||||
|
||||
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;
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
module.exports = require('../../util/createMetaModule.js')(
|
||||
function mapFunction(options) {
|
||||
|
||||
// return steps with options:
|
||||
return [
|
||||
{ '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 } }
|
||||
];
|
||||
}, {
|
||||
infoJson: require('./info.json')
|
||||
}
|
||||
|
||||
return {
|
||||
options: options,
|
||||
draw: draw,
|
||||
output: output,
|
||||
UI: UI
|
||||
}
|
||||
}
|
||||
)[0];
|
||||
|
||||
Reference in New Issue
Block a user