Pixel set redundancy removed (#1188)

* Pixels.set Redundancy removed

* eslint fixes

* move require to top with const
This commit is contained in:
aashna27
2019-08-15 01:04:14 +05:30
committed by Jeffrey Warren
parent 1b5607a339
commit 5b98d5cf44
16 changed files with 93 additions and 117 deletions

View File

@@ -1,9 +1,11 @@
module.exports = function Invert(options, UI) {
const pixelSetter = require('../../util/pixelSetter.js');
var output;
// The function which is called on every draw.
function draw(input, callback, progressObj) {
function draw(input, callback) {
var getPixels = require('get-pixels');
var savePixels = require('save-pixels');
@@ -21,10 +23,8 @@ module.exports = function Invert(options, UI) {
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);
pixelSetter(i, j, [val, val, val, 255], pixels);
}
}
var chunks = [];