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

@@ -3,92 +3,92 @@
*/
module.exports = function Channel(options, UI) {
var output;
var output;
function draw(input, callback, progressObj) {
function draw(input, callback, progressObj) {
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
options.gradient = options.gradient || defaults.gradient;
options.gradient = JSON.parse(options.gradient);
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
options.gradient = options.gradient || defaults.gradient;
options.gradient = JSON.parse(options.gradient);
progressObj.stop(true);
progressObj.overrideFlag = true;
progressObj.stop(true);
progressObj.overrideFlag = true;
var step = this, hist = new Array(256).fill(0);
var step = this, hist = new Array(256).fill(0);
function changePixel(r, g, b, a) {
let pixVal = Math.round((r + g + b) / 3);
hist[pixVal]++;
return [r, g, b, a];
function changePixel(r, g, b, a) {
let pixVal = Math.round((r + g + b) / 3);
hist[pixVal]++;
return [r, g, b, a];
}
function extraManipulation(pixels) {
// if (!options.inBrowser)
// require('fs').writeFileSync('./output/histo.txt', hist.reduce((tot, cur, idx) => `${tot}\n${idx} : ${cur}`, ``));
var newarray = new Uint8Array(4 * 256 * 256);
pixels.data = newarray;
pixels.shape = [256, 256, 4];
pixels.stride[1] = 4 * 256;
for (let x = 0; x < 256; x++) {
for (let y = 0; y < 256; y++) {
pixels.set(x, y, 0, 255);
pixels.set(x, y, 1, 255);
pixels.set(x, y, 2, 255);
pixels.set(x, y, 3, 255);
}
}
function extraManipulation(pixels) {
// if (!options.inBrowser)
// require('fs').writeFileSync('./output/histo.txt', hist.reduce((tot, cur, idx) => `${tot}\n${idx} : ${cur}`, ``));
var newarray = new Uint8Array(4 * 256 * 256);
pixels.data = newarray;
pixels.shape = [256, 256, 4];
pixels.stride[1] = 4 * 256;
for (let x = 0; x < 256; x++) {
for (let y = 0; y < 256; y++) {
pixels.set(x, y, 0, 255);
pixels.set(x, y, 1, 255);
pixels.set(x, y, 2, 255);
pixels.set(x, y, 3, 255);
}
}
let startY = options.gradient ? 10 : 0;
if (options.gradient) {
for (let x = 0; x < 256; x++) {
for (let y = 0; y < 10; y++) {
pixels.set(x, 255 - y, 0, x);
pixels.set(x, 255 - y, 1, x);
pixels.set(x, 255 - y, 2, x);
}
}
}
let convfactor = (256 - startY) / Math.max(...hist);
for (let x = 0; x < 256; x++) {
let pixCount = Math.round(convfactor * hist[x]);
for (let y = startY; y < pixCount; y++) {
pixels.set(x, 255 - y, 0, 204);
pixels.set(x, 255 - y, 1, 255);
pixels.set(x, 255 - y, 2, 153);
}
}
return pixels;
let startY = options.gradient ? 10 : 0;
if (options.gradient) {
for (let x = 0; x < 256; x++) {
for (let y = 0; y < 10; y++) {
pixels.set(x, 255 - y, 0, x);
pixels.set(x, 255 - y, 1, x);
pixels.set(x, 255 - y, 2, x);
}
}
}
function output(image, datauri, mimetype) {
let convfactor = (256 - startY) / Math.max(...hist);
// This output is accesible by Image Sequencer
step.output = { src: datauri, format: mimetype };
for (let x = 0; x < 256; x++) {
let pixCount = Math.round(convfactor * hist[x]);
for (let y = startY; y < pixCount; y++) {
pixels.set(x, 255 - y, 0, 204);
pixels.set(x, 255 - y, 1, 255);
pixels.set(x, 255 - y, 2, 153);
}
}
return require('../_nomodule/PixelManipulation.js')(input, {
output: output,
changePixel: changePixel,
extraManipulation: extraManipulation,
format: input.format,
image: options.image,
inBrowser: options.inBrowser,
callback: callback
});
return pixels;
}
function output(image, datauri, mimetype) {
// This output is accesible by Image Sequencer
step.output = { src: datauri, format: mimetype };
}
return {
options: options,
//setup: setup, // optional
draw: draw,
output: output,
UI: UI
}
}
return require('../_nomodule/PixelManipulation.js')(input, {
output: output,
changePixel: changePixel,
extraManipulation: extraManipulation,
format: input.format,
image: options.image,
inBrowser: options.inBrowser,
callback: callback
});
}
return {
options: options,
//setup: setup, // optional
draw: draw,
output: output,
UI: UI
};
};