Skip to content

Commit

Permalink
Merge branch 'mjmasn-fix/master/center_align_qr_code'
Browse files Browse the repository at this point in the history
  • Loading branch information
neocotic committed Nov 11, 2015
2 parents 698307a + 66f6b32 commit 5700640
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qr.js
Original file line number Diff line number Diff line change
Expand Up @@ -1045,18 +1045,20 @@
px /= width;
px = Math.floor(px);

var offset = Math.floor((size - (px * width)) / 2);

// Draw the QR code.
c2d.clearRect(0, 0, size, size);
c2d.fillStyle = data.background || '#fff';
c2d.fillRect(0, 0, px * (width + 8), px * (width + 8));
c2d.fillRect(0, 0, size, size);
c2d.fillStyle = data.foreground || '#000';

var i, j;

for (i = 0; i < width; i++) {
for (j = 0; j < width; j++) {
if (frame[j * width + i]) {
c2d.fillRect(px * i, px * j, px, px);
c2d.fillRect(px * i + offset, px * j + offset, px, px);
}
}
}
Expand Down

0 comments on commit 5700640

Please sign in to comment.