Skip to content

Commit

Permalink
Canvas size is margin + qr-code size + margin
Browse files Browse the repository at this point in the history
  • Loading branch information
Denys Kozak committed Jan 11, 2021
1 parent 06308af commit bd24a0c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/QRCanvas.ts
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ export default class QRCanvas {

async drawQR(qr: QRCode): Promise<void> {
const count = qr.getModuleCount();
const minSize = Math.min(this._options.width, this._options.height) - this._options.margin / 2;
const minSize = Math.min(this._options.width, this._options.height) - this._options.margin * 2;
const dotSize = Math.floor(minSize / count);
let drawImageSize = {
hideXDots: 0,
@@ -173,7 +173,7 @@ export default class QRCanvas {
throw "The canvas is too small.";
}

const minSize = Math.min(options.width, options.height) - options.margin;
const minSize = Math.min(options.width, options.height) - options.margin * 2;
const dotSize = Math.floor(minSize / count);
const xBeginning = Math.floor((options.width - count * dotSize) / 2);
const yBeginning = Math.floor((options.height - count * dotSize) / 2);
@@ -239,7 +239,7 @@ export default class QRCanvas {
const options = this._options;

const count = this._qr.getModuleCount();
const minSize = Math.min(options.width, options.height) - options.margin;
const minSize = Math.min(options.width, options.height) - options.margin * 2;
const dotSize = Math.floor(minSize / count);
const cornersSquareSize = dotSize * 7;
const cornersDotSize = dotSize * 3;

0 comments on commit bd24a0c

Please sign in to comment.