From 641ffd7a1a8e40363a857fd4820da2cddaef4cfe Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Mon, 27 May 2019 23:23:55 +0530 Subject: [PATCH] Fix overlay (#1082) * fix Overlay Signed-off-by: tech4GT * update canvas background color Signed-off-by: tech4GT --- src/modules/CanvasResize/Module.js | 2 +- src/modules/Overlay/Module.js | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/modules/CanvasResize/Module.js b/src/modules/CanvasResize/Module.js index 98221a3f..5d6aed95 100644 --- a/src/modules/CanvasResize/Module.js +++ b/src/modules/CanvasResize/Module.js @@ -21,7 +21,7 @@ module.exports = function canvasResize(options, UI) { var step = this; function extraManipulation(pixels) { - let newPixels = require('ndarray')(new Uint8Array(4 * options.width * options.height).fill(255), [options.width, options.height, 4]); + let newPixels = require('ndarray')(new Uint8Array(4 * options.width * options.height).fill(0), [options.width, options.height, 4]); let iMax = options.width - options.x, jMax = options.height - options.y; for (let i = 0; i < iMax && i < pixels.shape[0]; i++) { diff --git a/src/modules/Overlay/Module.js b/src/modules/Overlay/Module.js index 85ba59cf..3f5dee2b 100644 --- a/src/modules/Overlay/Module.js +++ b/src/modules/Overlay/Module.js @@ -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 = options.offset || -2; + options.offset = parseInt(options.offset) || -2; progressObj.stop(true); progressObj.overrideFlag = true; @@ -23,7 +23,7 @@ module.exports = function Dynamic(options, UI, util) { src: input.src, x: { valInp: options.x, type: 'horizontal' }, y: { valInp: options.y, type: 'vertical' }, - }, function (options, input) { + }, function(options, input) { options.x = parseInt(input.x.valInp); options.y = parseInt(input.y.valInp); }); @@ -34,7 +34,7 @@ module.exports = function Dynamic(options, UI, util) { var getPixels = require('get-pixels'); - getPixels(input.src, function (err, pixels) { + getPixels(input.src, function(err, pixels) { options.secondImagePixels = pixels; function changePixel(r1, g1, b1, a1, x, y) { @@ -42,14 +42,14 @@ module.exports = function Dynamic(options, UI, util) { // overlay var p = options.secondImagePixels; if (x >= options.x - && x < p.shape[0] - && y >= options.y - && y < p.shape[1]) + && x - options.x < p.shape[0] + && y >= options.y + && y - options.y < p.shape[1]) return [ - p.get(x, y, 0), - p.get(x, y, 1), - p.get(x, y, 2), - p.get(x, y, 3) + p.get(x - options.x, y - options.y, 0), + p.get(x - options.x, y - options.y, 1), + p.get(x - options.x, y - options.y, 2), + p.get(x - options.x, y - options.y, 3) ]; else return [r1, g1, b1, a1];