@liquid-js/qr-code-styling 5.4.3 → 5.4.5

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/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  JavaScript library for generating QR codes with customizable styling.
8
8
 
9
- Try it here <https://qrky.to/generator/">
9
+ Try it here <https://qrky.to/generator/>
10
10
 
11
11
  > 🌟 Check out [qr-code-styling-cli](https://www.npmjs.com/package/@liquid-js/qr-code-styling-cli) if you're looking to automate your QR generation process
12
12
 
@@ -1092,6 +1092,12 @@ class QRSVG {
1092
1092
  this._element.appendChild(image);
1093
1093
  }
1094
1094
  createColor(cfg) {
1095
+ let {width, height, x, y} = cfg;
1096
+ x -= this.options.dotsOptions.size, y -= this.options.dotsOptions.size, width += 2 * this.options.dotsOptions.size,
1097
+ height += 2 * this.options.dotsOptions.size;
1098
+ let rect = this.document.createElementNS("http://www.w3.org/2000/svg", "rect");
1099
+ rect.setAttribute("x", numToAttr(x)), rect.setAttribute("y", numToAttr(y)), rect.setAttribute("height", numToAttr(height)),
1100
+ rect.setAttribute("width", numToAttr(width)), rect.setAttribute("clip-path", `url(#mask-${cfg.name})`);
1095
1101
  let value = function({options, color, additionalRotation, x, y, height, width, name, dotSize: size, document}) {
1096
1102
  let gradientSize = width > height ? width : height;
1097
1103
  if (x -= size, y -= size, width += 2 * size, height += 2 * size, options) {
@@ -1136,16 +1142,9 @@ class QRSVG {
1136
1142
  dotSize: this.options.dotsOptions.size,
1137
1143
  document: this.document
1138
1144
  });
1139
- if (!value) return;
1140
- let {width, height, x, y} = cfg;
1141
- x -= this.options.dotsOptions.size, y -= this.options.dotsOptions.size, width += 2 * this.options.dotsOptions.size,
1142
- height += 2 * this.options.dotsOptions.size;
1143
- let rect = this.document.createElementNS("http://www.w3.org/2000/svg", "rect");
1144
- return rect.setAttribute("x", numToAttr(x)), rect.setAttribute("y", numToAttr(y)),
1145
- rect.setAttribute("height", numToAttr(height)), rect.setAttribute("width", numToAttr(width)),
1146
- rect.setAttribute("clip-path", `url(#mask-${cfg.name})`), rect.setAttribute("fill", value.value),
1147
- value.gradient && this.defs.appendChild(value.gradient), value.opacity < 1 && rect.setAttribute("opacity", value.opacity.toFixed(7)),
1148
- this._element.appendChild(rect), value;
1145
+ return value && (rect.setAttribute("fill", value.value), value.gradient && this.defs.appendChild(value.gradient),
1146
+ value.opacity < 1 && rect.setAttribute("opacity", value.opacity.toFixed(7))), this._element.appendChild(rect),
1147
+ value;
1149
1148
  }
1150
1149
  createMask(id) {
1151
1150
  let mask = this.document.createElementNS("http://www.w3.org/2000/svg", "clipPath");