Skip to content

Commit 287c727

Browse files
committed
Fixed quietZoneColor issue
Fixed `quietZoneColor` issue
1 parent 0c0aec2 commit 287c727

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

index.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* NodeJS QRCode generator. Can save image or svg to file, get standard base64 image data url text or get SVG serialized text. Cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title etc. settings. support binary mode.(Running without DOM on server side)
55
*
6-
* Version 4.2.0
6+
* Version 4.2.1
77
*
88
* @author [ [email protected] ]
99
*
@@ -1155,18 +1155,21 @@ Drawing.prototype.draw = function(oQRCode) {
11551155
var t = this;
11561156

11571157
function drawQuietZoneColor() {
1158-
// top
1159-
_oContext.lineWidth = 0;
1160-
_oContext.fillStyle = _htOption.quietZoneColor;
1161-
1162-
_oContext.fillRect(0, 0, t._canvas.width, _htOption.quietZone);
1163-
// left
1164-
_oContext.fillRect(0, _htOption.quietZone, _htOption.quietZone, t._canvas.height - _htOption.quietZone * 2);
1165-
// right
1166-
_oContext.fillRect(t._canvas.width - _htOption.quietZone, _htOption.quietZone, _htOption.quietZone, t._canvas
1167-
.height - _htOption.quietZone * 2);
1168-
// bottom
1169-
_oContext.fillRect(0, t._canvas.height - _htOption.quietZone, t._canvas.width, _htOption.quietZone);
1158+
if (_htOption.quietZone > 0 && _htOption.quietZoneColor) {
1159+
// top
1160+
_oContext.lineWidth = 0;
1161+
_oContext.fillStyle = _htOption.quietZoneColor;
1162+
1163+
_oContext.fillRect(0, 0, t._canvas.width, _htOption.quietZone);
1164+
// left
1165+
_oContext.fillRect(0, _htOption.quietZone, _htOption.quietZone, t._canvas.height - _htOption.quietZone *
1166+
2);
1167+
// right
1168+
_oContext.fillRect(t._canvas.width - _htOption.quietZone, _htOption.quietZone, _htOption.quietZone, t._canvas
1169+
.height - _htOption.quietZone * 2);
1170+
// bottom
1171+
_oContext.fillRect(0, t._canvas.height - _htOption.quietZone, t._canvas.width, _htOption.quietZone);
1172+
}
11701173
}
11711174

11721175
if (_htOption.backgroundImage) {
@@ -1369,12 +1372,8 @@ Drawing.prototype.draw = function(oQRCode) {
13691372
_oContext.drawImage(img, imgContainerX + (imgContainerW - imgW) / 2, imgContainerY +
13701373
(imgContainerH - imgH) / 2, imgW, imgH);
13711374

1375+
drawQuietZoneColor();
13721376
_this._bIsPainted = true;
1373-
1374-
if (_htOption.quietZone > 0 && _htOption.quietZoneColor) {
1375-
drawQuietZoneColor();
1376-
}
1377-
13781377
_this.makeImage();
13791378
}
13801379

@@ -1395,10 +1394,8 @@ Drawing.prototype.draw = function(oQRCode) {
13951394
}
13961395

13971396
} else {
1397+
drawQuietZoneColor();
13981398
this._bIsPainted = true;
1399-
if (_htOption.quietZone > 0 && _htOption.quietZoneColor) {
1400-
drawQuietZoneColor();
1401-
}
14021399
this.makeImage();
14031400
}
14041401

0 commit comments

Comments
 (0)