@liquid-js/qr-code-styling 1.10.0 → 1.10.1

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.
@@ -21,6 +21,7 @@ export interface RequiredOptions extends Options {
21
21
  type: DotType;
22
22
  color: string;
23
23
  gradient?: Gradient;
24
+ size: number;
24
25
  };
25
26
  }
26
27
  export declare const defaultOptions: RequiredOptions;
@@ -183,7 +183,8 @@ const defaultOptions = {
183
183
  },
184
184
  dotsOptions: {
185
185
  type: exports.DotType.square,
186
- color: "#000"
186
+ color: "#000",
187
+ size: 10
187
188
  }
188
189
  };
189
190
 
@@ -773,9 +774,7 @@ class QRSVG {
773
774
  }
774
775
  async drawQR(qr) {
775
776
  const count = qr.getModuleCount();
776
- const minSize = Math.min(this._options.width, this._options.height);
777
- const realQRSize = this._options.shape === exports.ShapeType.circle ? minSize / Math.sqrt(2) : minSize;
778
- const dotSize = Math.floor(realQRSize / (count + 2 * this._options.margin));
777
+ const dotSize = this._options.dotsOptions.size;
779
778
  let drawImageSize = {
780
779
  hideXDots: 0,
781
780
  hideYDots: 0,
@@ -860,8 +859,7 @@ class QRSVG {
860
859
  throw "The canvas is too small.";
861
860
  }
862
861
  const minSize = Math.min(options.width, options.height);
863
- const realQRSize = options.shape === exports.ShapeType.circle ? minSize / Math.sqrt(2) : minSize;
864
- const dotSize = Math.floor(realQRSize / (count + 2 * this._options.margin));
862
+ const dotSize = this._options.dotsOptions.size;
865
863
  const xBeginning = Math.floor((options.width - count * dotSize) / 2);
866
864
  const yBeginning = Math.floor((options.height - count * dotSize) / 2);
867
865
  const dot = new QRDot({ svg: this._element, type: options.dotsOptions.type, document: this._document });
@@ -949,9 +947,7 @@ class QRSVG {
949
947
  throw "Element code is not defined";
950
948
  }
951
949
  const count = this._qr.getModuleCount();
952
- const minSize = Math.min(options.width, options.height);
953
- const realQRSize = options.shape === exports.ShapeType.circle ? minSize / Math.sqrt(2) : minSize;
954
- const dotSize = Math.floor(realQRSize / (count + 2 * this._options.margin));
950
+ const dotSize = this._options.dotsOptions.size;
955
951
  const cornersSquareSize = dotSize * 7;
956
952
  const cornersDotSize = dotSize * 3;
957
953
  const xBeginning = Math.floor((options.width - count * dotSize) / 2);
@@ -1177,8 +1173,13 @@ let QRCodeStyling$1 = class QRCodeStyling {
1177
1173
  if (!this._qr) {
1178
1174
  return;
1179
1175
  }
1180
- this._options.width = this._options.height = 10 * (this._qr.getModuleCount() + 2 * this._options.margin);
1181
- const qrSVG = new QRSVG(this._options);
1176
+ const count = Math.ceil((this._options.shape == exports.ShapeType.circle ? Math.sqrt(2) : 1) * this._qr.getModuleCount());
1177
+ const size = this._options.dotsOptions.size * (count + 2 * this._options.margin);
1178
+ const qrSVG = new QRSVG({
1179
+ ...this._options,
1180
+ width: size,
1181
+ height: size
1182
+ });
1182
1183
  this._svg = qrSVG.getElement();
1183
1184
  this._svgDrawingPromise = qrSVG.drawQR(this._qr).then(() => {
1184
1185
  if (!this._svg)