Skip to content

Commit b7ba22d

Browse files
committed
Bug fixed
# SVG optimization # Fixed crossOrigin bug # Fixed timing color bug
1 parent 3fae200 commit b7ba22d

File tree

4 files changed

+31
-20
lines changed

4 files changed

+31
-20
lines changed

dist/easy.qrcode.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "easyqrcodejs",
3-
"version": "4.2.0",
3+
"version": "4.2.1",
44
"description": "Cross-browser QRCode generator for pure javascript. Support Canvas, SVG and Table drawing methods. Support Dot style, Logo, Background image, Colorful, Title etc. settings. Support Angular, Vue.js, React, Next.js framework. Support binary(hex) data mode.(Running with DOM on client side)",
55
"main": "dist/easy.qrcode.min.js",
66
"scripts": {},

src/canvas2svg.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,8 @@
780780
x : x,
781781
y : y,
782782
width : width,
783-
height : height
783+
height : height,
784+
"shape-rendering":"crispEdges"
784785
}, true);
785786
parent = this.__closestGroupOrSvg();
786787
parent.appendChild(rect);

src/easy.qrcode.js

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Cross-browser QRCode generator for pure javascript. Support Canvas, SVG and Table drawing methods. Support Dot style, Logo, Background image, Colorful, Title etc. settings. Support Angular, Vue.js, React, Next.js framework. Support binary(hex) data mode.(Running with DOM on client side)
55
*
6-
* Version 4.1.0
6+
* Version 4.2.1
77
*
88
* @author [ [email protected] ]
99
*
@@ -1284,15 +1284,15 @@
12841284
} else {
12851285
// canvas
12861286
// this._elImage.crossOrigin='Anonymous';
1287-
if (_htOption.crossOrigin != null) {
1288-
this._elImage.crossOrigin = _htOption.crossOrigin;
1289-
}
12901287
try {
1288+
// if (this._htOption.crossOrigin != null) {
1289+
// this._elImage.crossOrigin = this._htOption.crossOrigin;
1290+
// }
12911291
var dataURL = this._elCanvas.toDataURL("image/png");
1292-
this._elImage.src = dataURL;
1292+
// this._elImage.src = dataURL;
12931293
this.dataURL = dataURL;
1294-
this._elImage.style.display = "inline";
1295-
this._elCanvas.style.display = "none";
1294+
// this._elImage.style.display = "inline";
1295+
// this._elCanvas.style.display = "none";
12961296
} catch (e) {
12971297
console.error(e)
12981298
}
@@ -1395,10 +1395,10 @@
13951395
this._elCanvas = document.createElement("canvas");
13961396
this._el.appendChild(this._elCanvas);
13971397
this._oContext = this._elCanvas.getContext("2d");
1398-
this._elImage = document.createElement("img");
1399-
this._elImage.alt = "Scan me!";
1400-
this._elImage.style.display = "none";
1401-
this._el.appendChild(this._elImage);
1398+
// this._elImage = document.createElement("img");
1399+
// this._elImage.alt = "Scan me!";
1400+
// this._elImage.style.display = "none";
1401+
// this._el.appendChild(this._elImage);
14021402
}
14031403

14041404
this._bSupportDataURI = null;
@@ -1412,7 +1412,7 @@
14121412
*/
14131413
Drawing.prototype.draw = function(oQRCode) {
14141414

1415-
var _elImage = this._elImage;
1415+
// var _elImage = this._elImage;
14161416
var _htOption = this._htOption;
14171417

14181418

@@ -1435,9 +1435,9 @@
14351435
this._elCanvas.width = _htOption.width + _htOption.quietZone * 2;
14361436
this._elCanvas.height = _htOption.height + _htOption.quietZone * 2;
14371437

1438-
if (this._htOption.drawer == 'canvas') {
1439-
_elImage.style.display = "none";
1440-
} else {
1438+
if (this._htOption.drawer != 'canvas') {
1439+
// _elImage.style.display = "none";
1440+
// } else {
14411441
this._oContext = new C2S(this._elCanvas.width, this._elCanvas.height);
14421442
}
14431443
this.clear();
@@ -1565,6 +1565,11 @@
15651565

15661566
if (row == 6) {
15671567
// Timing Pattern
1568+
var timingHColorDark = _htOption.timing_H || _htOption.timing ||
1569+
_htOption.colorDark;
1570+
_oContext.fillStyle = bIsDark ? timingHColorDark : _htOption.colorLight;
1571+
_oContext.strokeStyle = _oContext.fillStyle;
1572+
15681573
nowDotScale = _htOption.dotScaleTiming_H;
15691574

15701575
_oContext.fillRect(nLeft + nWidth * (1 - nowDotScale) / 2, _htOption.titleHeight +
@@ -1573,6 +1578,11 @@
15731578
nowDotScale);
15741579
} else if (col == 6) {
15751580
// Timing Pattern
1581+
var timingVColorDark = _htOption.timing_V || _htOption.timing ||
1582+
_htOption.colorDark;
1583+
_oContext.fillStyle = bIsDark ? timingVColorDark : _htOption.colorLight;
1584+
_oContext.strokeStyle = _oContext.fillStyle;
1585+
15761586
nowDotScale = _htOption.dotScaleTiming_V;
15771587

15781588
_oContext.fillRect(nLeft + nWidth * (1 - nowDotScale) / 2, _htOption.titleHeight +

0 commit comments

Comments
 (0)