Added options startingX and startingY in Add-Qr Module (#1520)

* Added options startingX and startingY in Add-Qr Module

* requeste changes

* Fixing Qr Code at the end when not fit in the image

Co-authored-by: Rishabh Shukla <42492389+blurry-x-face@users.noreply.github.com>
This commit is contained in:
Naman Aggarwal
2020-01-19 06:18:52 +05:30
committed by Jeffrey Warren
parent 2fba0d2074
commit 2b3e5a2915
4 changed files with 34 additions and 9 deletions

View File

@@ -12,11 +12,11 @@ module.exports = exports = function (options, pixels, oldPixels, cb) {
const width = oldPixels.shape[0],
height = oldPixels.shape[1];
const xe = width - options.size, // Starting pixel coordinates
ye = height - options.size;
for (let x = xe; x < width; x++) {
for (let y = ye; y < height; y++) {
const xe = Math.min(options.startingX, width - options.size), // Starting pixel coordinates
ye = Math.min(options.startingY, height - options.size);
for (let x = xe; x < Math.min(xe + options.size, width); x++) {
for (let y = ye; y < Math.min(ye + options.size, height); y++) {
pixelSetter(
x,
y,