@liquid-js/qr-code-styling 1.9.1 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/core/QROptions.d.ts
CHANGED
|
@@ -168,6 +168,7 @@ const defaultOptions = {
|
|
|
168
168
|
shape: exports.ShapeType.square,
|
|
169
169
|
width: undefined,
|
|
170
170
|
height: undefined,
|
|
171
|
+
margin: 0,
|
|
171
172
|
data: "",
|
|
172
173
|
qrOptions: {
|
|
173
174
|
typeNumber: TypeNumber[0],
|
|
@@ -774,7 +775,7 @@ class QRSVG {
|
|
|
774
775
|
const count = qr.getModuleCount();
|
|
775
776
|
const minSize = Math.min(this._options.width, this._options.height);
|
|
776
777
|
const realQRSize = this._options.shape === exports.ShapeType.circle ? minSize / Math.sqrt(2) : minSize;
|
|
777
|
-
const dotSize = Math.floor(realQRSize / count);
|
|
778
|
+
const dotSize = Math.floor(realQRSize / (count + 2 * this._options.margin));
|
|
778
779
|
let drawImageSize = {
|
|
779
780
|
hideXDots: 0,
|
|
780
781
|
hideYDots: 0,
|
|
@@ -860,7 +861,7 @@ class QRSVG {
|
|
|
860
861
|
}
|
|
861
862
|
const minSize = Math.min(options.width, options.height);
|
|
862
863
|
const realQRSize = options.shape === exports.ShapeType.circle ? minSize / Math.sqrt(2) : minSize;
|
|
863
|
-
const dotSize = Math.floor(realQRSize / count);
|
|
864
|
+
const dotSize = Math.floor(realQRSize / (count + 2 * this._options.margin));
|
|
864
865
|
const xBeginning = Math.floor((options.width - count * dotSize) / 2);
|
|
865
866
|
const yBeginning = Math.floor((options.height - count * dotSize) / 2);
|
|
866
867
|
const dot = new QRDot({ svg: this._element, type: options.dotsOptions.type, document: this._document });
|
|
@@ -898,7 +899,7 @@ class QRSVG {
|
|
|
898
899
|
}
|
|
899
900
|
}
|
|
900
901
|
if (options.shape === exports.ShapeType.circle) {
|
|
901
|
-
const additionalDots = Math.floor((minSize / dotSize - count) / 2);
|
|
902
|
+
const additionalDots = Math.floor((minSize / dotSize - count - 2 * this._options.margin) / 2);
|
|
902
903
|
const fakeCount = count + additionalDots * 2;
|
|
903
904
|
const xFakeBeginning = xBeginning - additionalDots * dotSize;
|
|
904
905
|
const yFakeBeginning = yBeginning - additionalDots * dotSize;
|
|
@@ -950,7 +951,7 @@ class QRSVG {
|
|
|
950
951
|
const count = this._qr.getModuleCount();
|
|
951
952
|
const minSize = Math.min(options.width, options.height);
|
|
952
953
|
const realQRSize = options.shape === exports.ShapeType.circle ? minSize / Math.sqrt(2) : minSize;
|
|
953
|
-
const dotSize = Math.floor(realQRSize / count);
|
|
954
|
+
const dotSize = Math.floor(realQRSize / (count + 2 * this._options.margin));
|
|
954
955
|
const cornersSquareSize = dotSize * 7;
|
|
955
956
|
const cornersDotSize = dotSize * 3;
|
|
956
957
|
const xBeginning = Math.floor((options.width - count * dotSize) / 2);
|
|
@@ -1176,7 +1177,7 @@ let QRCodeStyling$1 = class QRCodeStyling {
|
|
|
1176
1177
|
if (!this._qr) {
|
|
1177
1178
|
return;
|
|
1178
1179
|
}
|
|
1179
|
-
this._options.width = this._options.height = 10 * this._qr.getModuleCount();
|
|
1180
|
+
this._options.width = this._options.height = 10 * (this._qr.getModuleCount() + 2 * this._options.margin);
|
|
1180
1181
|
const qrSVG = new QRSVG(this._options);
|
|
1181
1182
|
this._svg = qrSVG.getElement();
|
|
1182
1183
|
this._svgDrawingPromise = qrSVG.drawQR(this._qr).then(() => {
|