diff --git a/lib/qrcode.js b/lib/qrcode.js index 2514aaa..b36e22f 100644 --- a/lib/qrcode.js +++ b/lib/qrcode.js @@ -759,18 +759,12 @@ console.warn('No canvas provided to draw QR code in!') return; } - //边框大小 - const BORDER_SIZE = 0; var size = Math.min(cavW, cavH); str = that.utf16to8(str);//增加中文显示 - var frame = that.getFrame(str), + var frame = that.getFrame(str); // 组件中生成qrcode需要绑定this - px = Math.round(size / (width + BORDER_SIZE)); - var roundedSize = px * (width + 8), - offset = Math.floor((size - roundedSize) / 2); - size = roundedSize; - //ctx.clearRect(0, 0, cavW, cavW); + var px = size / width; if (bg) { ctx.setFillStyle(bg) ctx.fillRect(startX, startY, cavW, cavW); @@ -779,7 +773,7 @@ for (var i = 0; i < width; i++) { for (var j = 0; j < width; j++) { if (frame[j * width + i]) { - ctx.fillRect(startX + px * (4 + i) + offset, startY + px * (4 + j) + offset, px, px); + ctx.fillRect(startX + px * i, startY + px * j, px, px); } } }