mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-06 16:30:01 +01:00
Fixing defaults in various modules (#1441)
* Fix AddQr * Fix Threshold * Fix ReplaceColor Modulr * Fix Overlay Module * Fix FlipImage Module * fix Colorbar Module * Fix colormap module * fix overlay Co-authored-by: Harsh Khandeparkar <34770591+HarshKhandeparkar@users.noreply.github.com> Co-authored-by: Jeffrey Warren <jeff@unterbahn.com>
This commit is contained in:
committed by
Jeffrey Warren
parent
00ed0f148d
commit
d215b43a09
@@ -2,7 +2,7 @@ module.exports = function AddQR(options, UI) {
|
||||
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
options.size = options.size || defaults.size;
|
||||
options.qrCodeString = options.qrCodeString || 'https://github.com/publiclab/image-sequencer';
|
||||
options.qrCodeString = options.qrCodeString || defaults.qrCodeString;
|
||||
var output;
|
||||
getPixels = require('get-pixels');
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
module.exports = require('../../util/createMetaModule.js')(
|
||||
function mapFunction(options) {
|
||||
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
// 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 } }
|
||||
{ 'name': 'colormap', 'options': { colormap: options.colormap || defaults.colormap } },
|
||||
{ 'name': 'crop', 'options': { 'y': 0, 'h': options.h || defaults.h } },
|
||||
{ 'name': 'overlay', 'options': { 'x': options.x || defaults.x, 'y': options.y || defaults.y, 'offset': -4 } }
|
||||
];
|
||||
}, {
|
||||
infoJson: require('./info.json')
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
*/
|
||||
|
||||
module.exports = function Colormap(value, options) {
|
||||
options.colormap = options.colormap || colormaps.default;
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
options.colormap = options.colormap || defaults.colormap;
|
||||
// if a lookup table is provided as an array:
|
||||
if(typeof(options.colormap) == 'object')
|
||||
colormapFunction = colormap(options.colormap);
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
* Flip the image on vertical/horizontal axis.
|
||||
*/
|
||||
module.exports = function FlipImage(options, UI) {
|
||||
options.Axis = options.Axis || require('./info.json').inputs.Axis.default;
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
options.Axis = options.Axis || defaults.Axis;
|
||||
|
||||
var output,
|
||||
getPixels = require('get-pixels');
|
||||
|
||||
@@ -9,7 +9,7 @@ module.exports = function Dynamic(options, UI, util) {
|
||||
// This function is called on every draw.
|
||||
function draw(input, callback, progressObj) {
|
||||
|
||||
options.offset = parseInt(options.offset) || -2;
|
||||
options.offset = parseInt(options.offset || defaults.offset);
|
||||
|
||||
progressObj.stop(true);
|
||||
progressObj.overrideFlag = true;
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
module.exports = exports = function(pixels, options){
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
|
||||
var color = options.color || 'rgb(228,86,81)';
|
||||
var color = options.color || defaults.color;
|
||||
color = color.substring(color.indexOf('(') + 1, color.length - 1); // extract only the values from rgba(_,_,_,_)
|
||||
|
||||
var replaceColor = options.replaceColor || 'rgb(0,0,255)';
|
||||
var replaceColor = options.replaceColor || defaults.replaceColor;
|
||||
replaceColor = replaceColor.substring(replaceColor.indexOf('(') + 1, replaceColor.length - 1); // extract only the values from rgba(_,_,_,_)
|
||||
|
||||
var replaceMethod = options.replaceMethod || 'greyscale';
|
||||
var replaceMethod = options.replaceMethod || defaults.replaceMethod;
|
||||
color = color.split(',');
|
||||
replaceColor = replaceColor.split(',');
|
||||
|
||||
@@ -16,7 +17,7 @@ module.exports = exports = function(pixels, options){
|
||||
cg = color[1],
|
||||
cb = color[2];
|
||||
|
||||
var tolerance = options.tolerance || 50;
|
||||
var tolerance = options.tolerance || defaults.tolerance;
|
||||
var maxFactor = (1 + tolerance / 100);
|
||||
var minFactor = (1 - tolerance / 100);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module.exports = function Threshold(pixels, options, histData) {
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
|
||||
type = options.threshold ;
|
||||
type = options.threshold || defaults.threshold;
|
||||
threshold = parseInt(options.input) || defaults.input;
|
||||
var lumR = [];
|
||||
var lumG = [];
|
||||
|
||||
Reference in New Issue
Block a user