Added Eslint and husky (#1062)

This commit is contained in:
aashna27
2019-05-11 20:09:15 +05:30
committed by Jeffrey Warren
parent 0c3d7be7e2
commit c784de0c19
203 changed files with 3288 additions and 3250 deletions

View File

@@ -1,61 +1,61 @@
module.exports = function Invert(options, UI) {
var output;
var output;
// The function which is called on every draw.
function draw(input, callback, progressObj) {
var getPixels = require('get-pixels');
var savePixels = require('save-pixels');
// The function which is called on every draw.
function draw(input, callback, progressObj) {
var getPixels = require('get-pixels');
var savePixels = require('save-pixels');
var step = this;
var step = this;
getPixels(input.src, function(err, pixels) {
getPixels(input.src, function(err, pixels) {
if (err) {
console.log("Bad Image path");
return;
}
if (err) {
console.log('Bad Image path');
return;
}
var width = pixels.shape[0];
for (var i = 0; i < pixels.shape[0]; i++) {
for (var j = 0; j < pixels.shape[1]; j++) {
let val = (i / width) * 255;
pixels.set(i, j, 0, val);
pixels.set(i, j, 1, val);
pixels.set(i, j, 2, val);
pixels.set(i, j, 3, 255);
}
}
var chunks = [];
var totalLength = 0;
var r = savePixels(pixels, input.format, { quality: 100 });
r.on("data", function(chunk) {
totalLength += chunk.length;
chunks.push(chunk);
});
r.on("end", function() {
var data = Buffer.concat(chunks, totalLength).toString("base64");
var datauri = "data:image/" + input.format + ";base64," + data;
output(input.image, datauri, input.format);
callback();
});
});
function output(image, datauri, mimetype) {
// This output is accessible by Image Sequencer
step.output = { src: datauri, format: mimetype };
var width = pixels.shape[0];
for (var i = 0; i < pixels.shape[0]; i++) {
for (var j = 0; j < pixels.shape[1]; j++) {
let val = (i / width) * 255;
pixels.set(i, j, 0, val);
pixels.set(i, j, 1, val);
pixels.set(i, j, 2, val);
pixels.set(i, j, 3, 255);
}
}
}
var chunks = [];
var totalLength = 0;
var r = savePixels(pixels, input.format, { quality: 100 });
r.on('data', function(chunk) {
totalLength += chunk.length;
chunks.push(chunk);
});
r.on('end', function() {
var data = Buffer.concat(chunks, totalLength).toString('base64');
var datauri = 'data:image/' + input.format + ';base64,' + data;
output(input.image, datauri, input.format);
callback();
});
});
function output(image, datauri, mimetype) {
// This output is accessible by Image Sequencer
step.output = { src: datauri, format: mimetype };
return {
options: options,
draw: draw,
output: output,
UI: UI
}
}
}
return {
options: options,
draw: draw,
output: output,
UI: UI
};
};