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:
Varun Gupta
2019-02-16 22:33:45 +05:30
committed by GitHub
parent 81b06d1b42
commit 761142d9d3
11 changed files with 262 additions and 199 deletions

View File

@@ -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];