From 47f7d9ab70b54901843b4950c01666054067733b Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Thu, 10 Mar 2016 16:07:06 -0500 Subject: [PATCH] Fixed rounding issue. --- lib/QRCode.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/QRCode.js b/lib/QRCode.js index d2cc578..bddc95e 100644 --- a/lib/QRCode.js +++ b/lib/QRCode.js @@ -25,8 +25,8 @@ function renderCanvas(canvas) { cells.forEach(function(row, rowIndex) { row.forEach(function(column, columnIndex) { ctx.fillStyle = column ? bgColor : fgColor; - var w = Math.ceil((rowIndex + 1) * cellWidth) - Math.floor(rowIndex * cellWidth); - var h = Math.ceil((columnIndex + 1) * cellHeight) - Math.floor(columnIndex * cellHeight); + var w = Math.round((rowIndex + 1) * cellWidth) - Math.round(rowIndex * cellWidth); + var h = Math.round((columnIndex + 1) * cellHeight) - Math.round(columnIndex * cellHeight); ctx.fillRect(Math.round(rowIndex * cellWidth), Math.round(columnIndex * cellHeight), w, h); }); });