From 5c8d3b3c1a4af0564f1661512b5473b7b8754847 Mon Sep 17 00:00:00 2001 From: CPPAlien Date: Tue, 17 Jul 2018 11:49:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=8C=E7=BB=B4=E7=A0=81?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=20#11?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/qrcode.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) 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); } } }