@liquid-js/qr-code-styling 2.2.1 → 2.2.3

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2019 Denys Kozak
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Denys Kozak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -34,7 +34,7 @@ export declare class QRCodeStyling {
34
34
  * const extension = (svg, options) => {
35
35
  * const { width, height } = options;
36
36
  * const size = Math.min(width, height);
37
- * const border = document.createElementNS("http://www.w3.org/2000/svg", "rect");
37
+ * const border = options.document.createElementNS("http://www.w3.org/2000/svg", "rect");
38
38
  * const borderAttributes = {
39
39
  * fill: "none",
40
40
  * x: (width - size + 40) / 2,
@@ -16,7 +16,6 @@ export declare class QRCornerDot {
16
16
  _basicHeart(args: BasicFigureDrawArgs): void;
17
17
  _basicRounded(args: BasicFigureDrawArgs): void;
18
18
  _basicClassy(args: BasicFigureDrawArgs): void;
19
- _basicOutpoint(args: BasicFigureDrawArgs): void;
20
19
  _basicInpoint(args: BasicFigureDrawArgs): void;
21
20
  _drawDot({ x, y, size, rotation }: DrawArgs): void;
22
21
  _drawSquare({ x, y, size, rotation }: DrawArgs): void;
@@ -15,12 +15,11 @@ export declare class QRCornerSquare {
15
15
  _basicSquare(args: BasicFigureDrawArgs): void;
16
16
  _basicExtraRounded(args: BasicFigureDrawArgs): void;
17
17
  _basicClassy(args: BasicFigureDrawArgs): void;
18
- _basicOutpoint(args: BasicFigureDrawArgs): void;
19
18
  _basicInpoint(args: BasicFigureDrawArgs): void;
20
19
  _drawDot({ x, y, size, rotation }: DrawArgs): void;
21
20
  _drawSquare({ x, y, size, rotation }: DrawArgs): void;
22
21
  _drawExtraRounded({ x, y, size, rotation }: DrawArgs): void;
23
22
  _drawClassy({ x, y, size, rotation }: DrawArgs): void;
24
- _drawOutpoint({ x, y, size, rotation }: DrawArgs): void;
25
23
  _drawInpoint({ x, y, size, rotation }: DrawArgs): void;
24
+ _drawOutpoint({ x, y, size, rotation }: DrawArgs): void;
26
25
  }
@@ -398,7 +398,7 @@ class QRCornerDot {
398
398
  this._rotateFigure({
399
399
  ...args,
400
400
  draw: () => {
401
- this._element = document.createElementNS("http://www.w3.org/2000/svg", "rect");
401
+ this._element = this._document.createElementNS("http://www.w3.org/2000/svg", "rect");
402
402
  this._element.setAttribute("x", String(x));
403
403
  this._element.setAttribute("y", String(y));
404
404
  this._element.setAttribute("width", String(size));
@@ -414,7 +414,7 @@ class QRCornerDot {
414
414
  this._rotateFigure({
415
415
  ...args,
416
416
  draw: () => {
417
- this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
417
+ this._element = this._document.createElementNS("http://www.w3.org/2000/svg", "path");
418
418
  this._element.setAttribute("clip-rule", "evenodd");
419
419
  this._element.setAttribute("d", `M ${x} ${y + 2.5 * dotSize}` +
420
420
  `v ${2 * dotSize}` +
@@ -428,33 +428,13 @@ class QRCornerDot {
428
428
  }
429
429
  });
430
430
  }
431
- _basicOutpoint(args) {
432
- const { size, x, y } = args;
433
- const dotSize = size;
434
- this._rotateFigure({
435
- ...args,
436
- draw: () => {
437
- this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
438
- this._element.setAttribute("clip-rule", "evenodd");
439
- this._element.setAttribute("d", `M ${x} ${y + dotSize / 2}` +
440
- `v ${dotSize / 4}` +
441
- `a ${dotSize / 4}, ${dotSize / 4} 0 0 0 ${dotSize / 4}, ${dotSize / 4}` +
442
- `h ${dotSize / 2}` +
443
- `a ${dotSize / 4}, ${dotSize / 4} 0 0 0 ${dotSize / 4}, ${-dotSize / 4}` +
444
- `v ${-dotSize / 2}` +
445
- `a ${dotSize / 4}, ${dotSize / 4} 0 0 0 ${-dotSize / 4}, ${-dotSize / 4}` +
446
- `h ${(-dotSize / 4) * 3}` +
447
- `z`);
448
- }
449
- });
450
- }
451
431
  _basicInpoint(args) {
452
432
  const { size, x, y } = args;
453
433
  const dotSize = size;
454
434
  this._rotateFigure({
455
435
  ...args,
456
436
  draw: () => {
457
- this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
437
+ this._element = this._document.createElementNS("http://www.w3.org/2000/svg", "path");
458
438
  this._element.setAttribute("clip-rule", "evenodd");
459
439
  this._element.setAttribute("d", `M ${x} ${y + dotSize / 2}` +
460
440
  `v ${dotSize / 4}` +
@@ -493,7 +473,7 @@ class QRCornerDot {
493
473
  this._basicInpoint({ x, y, size, rotation });
494
474
  }
495
475
  _drawOutpoint({ x, y, size, rotation }) {
496
- this._basicOutpoint({ x, y, size, rotation });
476
+ this._basicInpoint({ x, y, size, rotation: (rotation || 0) + Math.PI });
497
477
  }
498
478
  }
499
479
 
@@ -608,7 +588,7 @@ class QRCornerSquare {
608
588
  this._rotateFigure({
609
589
  ...args,
610
590
  draw: () => {
611
- this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
591
+ this._element = this._document.createElementNS("http://www.w3.org/2000/svg", "path");
612
592
  this._element.setAttribute("clip-rule", "evenodd");
613
593
  this._element.setAttribute("d", `M ${x} ${y + 2.5 * dotSize}` +
614
594
  `v ${2 * dotSize}` +
@@ -630,42 +610,13 @@ class QRCornerSquare {
630
610
  }
631
611
  });
632
612
  }
633
- _basicOutpoint(args) {
634
- const { size, x, y } = args;
635
- const dotSize = size / 7;
636
- this._rotateFigure({
637
- ...args,
638
- draw: () => {
639
- this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
640
- this._element.setAttribute("clip-rule", "evenodd");
641
- this._element.setAttribute("d", `M ${x} ${y + 2.5 * dotSize}` +
642
- `v ${2 * dotSize}` +
643
- `a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${dotSize * 2.5} ${dotSize * 2.5}` +
644
- `h ${2 * dotSize}` +
645
- `a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${dotSize * 2.5} ${-dotSize * 2.5}` +
646
- `v ${-2 * dotSize}` +
647
- `a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${-dotSize * 2.5} ${-dotSize * 2.5}` +
648
- `h ${-2 * dotSize}` +
649
- `a ${dotSize} ${2.5 * dotSize}, 0, 0, 0, ${-dotSize * 2.5} ${dotSize * 2.5}` +
650
- `M ${x + 2.5 * dotSize} ${y + dotSize}` +
651
- `h ${2 * dotSize}` +
652
- `a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${dotSize * 1.5} ${dotSize * 1.5}` +
653
- `v ${2 * dotSize}` +
654
- `a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${-dotSize * 1.5} ${dotSize * 1.5}` +
655
- `h ${-2 * dotSize}` +
656
- `a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${-dotSize * 1.5} ${-dotSize * 1.5}` +
657
- `v ${-2 * dotSize}` +
658
- `l 0 ${-dotSize * 1.5}`);
659
- }
660
- });
661
- }
662
613
  _basicInpoint(args) {
663
614
  const { size, x, y } = args;
664
615
  const dotSize = size / 7;
665
616
  this._rotateFigure({
666
617
  ...args,
667
618
  draw: () => {
668
- this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
619
+ this._element = this._document.createElementNS("http://www.w3.org/2000/svg", "path");
669
620
  this._element.setAttribute("clip-rule", "evenodd");
670
621
  this._element.setAttribute("d", `M ${x} ${y + 2.5 * dotSize}` +
671
622
  `v ${2 * dotSize}` +
@@ -698,12 +649,12 @@ class QRCornerSquare {
698
649
  _drawClassy({ x, y, size, rotation }) {
699
650
  this._basicClassy({ x, y, size, rotation });
700
651
  }
701
- _drawOutpoint({ x, y, size, rotation }) {
702
- this._basicOutpoint({ x, y, size, rotation });
703
- }
704
652
  _drawInpoint({ x, y, size, rotation }) {
705
653
  this._basicInpoint({ x, y, size, rotation });
706
654
  }
655
+ _drawOutpoint({ x, y, size, rotation }) {
656
+ this._basicInpoint({ x, y, size, rotation: (rotation || 0) + Math.PI });
657
+ }
707
658
  }
708
659
 
709
660
  class QRDot {
@@ -1685,7 +1636,7 @@ let QRCodeStyling$1 = class QRCodeStyling {
1685
1636
  * const extension = (svg, options) => {
1686
1637
  * const { width, height } = options;
1687
1638
  * const size = Math.min(width, height);
1688
- * const border = document.createElementNS("http://www.w3.org/2000/svg", "rect");
1639
+ * const border = options.document.createElementNS("http://www.w3.org/2000/svg", "rect");
1689
1640
  * const borderAttributes = {
1690
1641
  * fill: "none",
1691
1642
  * x: (width - size + 40) / 2,