@liquid-js/qr-code-styling 3.1.2 → 4.0.0-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/qr-svg.d.ts +4 -1
- package/lib/figures/corner-square.d.ts +2 -0
- package/lib/figures/dot.d.ts +1 -0
- package/lib/index.d.ts +4 -4
- package/lib/kanji.js +1 -1
- package/lib/kanji.js.map +1 -1
- package/lib/node.d.ts +1 -1
- package/lib/qr-code-styling-node.js +183 -102
- package/lib/qr-code-styling-node.js.map +1 -1
- package/lib/qr-code-styling.js +1 -1
- package/lib/qr-code-styling.js.map +1 -1
- package/lib/utils/options.d.ts +29 -5
- package/lib/utils/qrcode.d.ts +1 -1
- package/package.json +10 -7
- package/lib/types/qrcode.d.ts +0 -22
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { QRUtil } from "@liquid-js/qrcode-generator/lib/qrcode/QRUtil.js";
|
|
2
|
+
|
|
3
|
+
import { stringToBytes_UTF8 } from "@liquid-js/qrcode-generator/lib/text/stringToBytes_UTF8.js";
|
|
4
|
+
|
|
5
|
+
import { TypeNumber, ErrorCorrectionLevel, Mode, QRCodeMinimal } from "@liquid-js/qrcode-generator/lib/qrcode/QRCodeMinimal.js";
|
|
2
6
|
|
|
3
7
|
import sharp from "sharp";
|
|
4
8
|
|
|
@@ -6,14 +10,7 @@ import { fileTypeFromBuffer } from "file-type";
|
|
|
6
10
|
|
|
7
11
|
import { DOMImplementation, XMLSerializer as XMLSerializer$1, DOMParser as DOMParser$1 } from "@xmldom/xmldom";
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var ErrorCorrectionLevel, Mode;
|
|
12
|
-
|
|
13
|
-
(ErrorCorrectionLevel = ErrorCorrectionLevel || (ErrorCorrectionLevel = {})).L = "L",
|
|
14
|
-
ErrorCorrectionLevel.M = "M", ErrorCorrectionLevel.Q = "Q", ErrorCorrectionLevel.H = "H",
|
|
15
|
-
(Mode = Mode || (Mode = {})).numeric = "Numeric", Mode.alphanumeric = "Alphanumeric",
|
|
16
|
-
Mode.byte = "Byte", Mode.kanji = "Kanji", Mode.unicode = "Unicode";
|
|
13
|
+
export { ErrorCorrectionLevel, Mode, TypeNumber } from "@liquid-js/qrcode-generator/lib/qrcode/QRCodeMinimal.js";
|
|
17
14
|
|
|
18
15
|
let isObject = obj => !!obj && "object" == typeof obj && !Array.isArray(obj);
|
|
19
16
|
|
|
@@ -28,7 +25,7 @@ function mergeDeep(target, ...sources) {
|
|
|
28
25
|
})), mergeDeep(target, ...sources)) : target;
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
var GradientType, DotType, CornerDotType, CornerSquareType, ShapeType;
|
|
28
|
+
var GradientType, DotType, CornerDotType, CornerSquareType, ShapeType, ImageMode;
|
|
32
29
|
|
|
33
30
|
function sanitizeGradient(gradient_newGradient) {
|
|
34
31
|
if (!(gradient_newGradient = {
|
|
@@ -45,13 +42,15 @@ function sanitizeGradient(gradient_newGradient) {
|
|
|
45
42
|
(DotType = DotType || (DotType = {})).dot = "dot", DotType.randomDot = "random-dot",
|
|
46
43
|
DotType.rounded = "rounded", DotType.extraRounded = "extra-rounded", DotType.verticalLine = "vertical-line",
|
|
47
44
|
DotType.horizontalLine = "horizontal-line", DotType.classy = "classy", DotType.classyRounded = "classy-rounded",
|
|
48
|
-
DotType.square = "square", DotType.smallSquare = "small-square", DotType.
|
|
49
|
-
(CornerDotType = CornerDotType || (CornerDotType = {})).dot = "dot",
|
|
50
|
-
CornerDotType.
|
|
51
|
-
CornerDotType.
|
|
52
|
-
CornerSquareType.
|
|
53
|
-
CornerSquareType.
|
|
54
|
-
(ShapeType = ShapeType || (ShapeType = {})).square = "square",
|
|
45
|
+
DotType.square = "square", DotType.smallSquare = "small-square", DotType.tinySquare = "tiny-square",
|
|
46
|
+
DotType.diamond = "diamond", (CornerDotType = CornerDotType || (CornerDotType = {})).dot = "dot",
|
|
47
|
+
CornerDotType.square = "square", CornerDotType.heart = "heart", CornerDotType.extraRounded = "extra-rounded",
|
|
48
|
+
CornerDotType.classy = "classy", CornerDotType.outpoint = "outpoint", CornerDotType.inpoint = "inpoint",
|
|
49
|
+
(CornerSquareType = CornerSquareType || (CornerSquareType = {})).dot = "dot", CornerSquareType.square = "square",
|
|
50
|
+
CornerSquareType.extraRounded = "extra-rounded", CornerSquareType.classy = "classy",
|
|
51
|
+
CornerSquareType.outpoint = "outpoint", CornerSquareType.inpoint = "inpoint", (ShapeType = ShapeType || (ShapeType = {})).square = "square",
|
|
52
|
+
ShapeType.circle = "circle", (ImageMode = ImageMode || (ImageMode = {})).center = "center",
|
|
53
|
+
ImageMode.background = "background";
|
|
55
54
|
|
|
56
55
|
let defaultOptions = {
|
|
57
56
|
document: void 0,
|
|
@@ -65,10 +64,13 @@ let defaultOptions = {
|
|
|
65
64
|
errorCorrectionLevel: ErrorCorrectionLevel.Q
|
|
66
65
|
},
|
|
67
66
|
imageOptions: {
|
|
68
|
-
|
|
67
|
+
mode: ImageMode.center,
|
|
69
68
|
imageSize: .4,
|
|
70
69
|
crossOrigin: void 0,
|
|
71
|
-
margin: 0
|
|
70
|
+
margin: 0,
|
|
71
|
+
fill: {
|
|
72
|
+
color: "rgba(255,255,255,1)"
|
|
73
|
+
}
|
|
72
74
|
},
|
|
73
75
|
dotsOptions: {
|
|
74
76
|
type: DotType.square,
|
|
@@ -82,10 +84,14 @@ function sanitizeOptions(newOptions_options) {
|
|
|
82
84
|
...newOptions_options
|
|
83
85
|
}).imageOptions = {
|
|
84
86
|
...newOptions_options.imageOptions,
|
|
85
|
-
hideBackgroundDots: !!newOptions_options.imageOptions.hideBackgroundDots,
|
|
86
87
|
imageSize: Math.min(1, Number(newOptions_options.imageOptions.imageSize)) || 1,
|
|
87
|
-
margin: Number(newOptions_options.imageOptions.margin)
|
|
88
|
-
|
|
88
|
+
margin: Number(newOptions_options.imageOptions.margin),
|
|
89
|
+
fill: {
|
|
90
|
+
...newOptions_options.imageOptions.fill
|
|
91
|
+
}
|
|
92
|
+
}, newOptions_options.imageOptions.mode == ImageMode.background && (newOptions_options.imageOptions.margin = 0),
|
|
93
|
+
newOptions_options.imageOptions.fill.gradient && (newOptions_options.imageOptions.fill.gradient = sanitizeGradient(newOptions_options.imageOptions.fill.gradient)),
|
|
94
|
+
newOptions_options.dotsOptions = {
|
|
89
95
|
...newOptions_options.dotsOptions
|
|
90
96
|
}, newOptions_options.dotsOptions.gradient && (newOptions_options.dotsOptions.gradient = sanitizeGradient(newOptions_options.dotsOptions.gradient)),
|
|
91
97
|
newOptions_options.dotsOptions.size = Math.round(Math.max(0, newOptions_options.dotsOptions.size) || 10),
|
|
@@ -287,6 +293,9 @@ class QRCornerSquare {
|
|
|
287
293
|
get element() {
|
|
288
294
|
return this._element;
|
|
289
295
|
}
|
|
296
|
+
get fill() {
|
|
297
|
+
return this._fill;
|
|
298
|
+
}
|
|
290
299
|
constructor(type, document) {
|
|
291
300
|
this.type = type, this.document = document;
|
|
292
301
|
}
|
|
@@ -319,7 +328,8 @@ class QRCornerSquare {
|
|
|
319
328
|
drawFunction.call(this, args);
|
|
320
329
|
}
|
|
321
330
|
rotateFigure({x: cx, y: cy, size, rotation = 0, draw}) {
|
|
322
|
-
cx += size / 2, cy += size / 2, draw(), this._element?.setAttribute("transform", `rotate(${numToAttr(180 * rotation / Math.PI)},${cx},${cy})`)
|
|
331
|
+
cx += size / 2, cy += size / 2, draw(), this._element?.setAttribute("transform", `rotate(${numToAttr(180 * rotation / Math.PI)},${cx},${cy})`),
|
|
332
|
+
this._fill?.setAttribute("transform", `rotate(${numToAttr(180 * rotation / Math.PI)},${cx},${cy})`);
|
|
323
333
|
}
|
|
324
334
|
basicDot(args) {
|
|
325
335
|
let {size, x, y} = args, dotSize = size / 7;
|
|
@@ -327,7 +337,9 @@ class QRCornerSquare {
|
|
|
327
337
|
...args,
|
|
328
338
|
draw: () => {
|
|
329
339
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
330
|
-
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", svgPath`M ${x + size / 2} ${y} a ${size / 2} ${size / 2} 0 1 0 0.1 0 z m 0 ${dotSize} a ${size / 2 - dotSize} ${size / 2 - dotSize} 0 1 1 -0.1 0 Z`)
|
|
340
|
+
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", svgPath`M ${x + size / 2} ${y} a ${size / 2} ${size / 2} 0 1 0 0.1 0 z m 0 ${dotSize} a ${size / 2 - dotSize} ${size / 2 - dotSize} 0 1 1 -0.1 0 Z`),
|
|
341
|
+
this._fill = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
342
|
+
this._fill.setAttribute("clip-rule", "evenodd"), this._fill.setAttribute("d", svgPath`M ${x + size / 2} ${y - dotSize} a ${size / 2 + dotSize} ${size / 2 + dotSize} 0 1 0 0.1 0 z`);
|
|
331
343
|
}
|
|
332
344
|
});
|
|
333
345
|
}
|
|
@@ -337,7 +349,9 @@ class QRCornerSquare {
|
|
|
337
349
|
...args,
|
|
338
350
|
draw: () => {
|
|
339
351
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
340
|
-
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", svgPath`M ${x} ${y} v ${size} h ${size} v ${-size} z M ${x + dotSize} ${y + dotSize} h ${size - 2 * dotSize} v ${size - 2 * dotSize} h ${2 * dotSize - size} z`)
|
|
352
|
+
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", svgPath`M ${x} ${y} v ${size} h ${size} v ${-size} z M ${x + dotSize} ${y + dotSize} h ${size - 2 * dotSize} v ${size - 2 * dotSize} h ${2 * dotSize - size} z`),
|
|
353
|
+
this._fill = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
354
|
+
this._fill.setAttribute("clip-rule", "evenodd"), this._fill.setAttribute("d", svgPath`M ${x - dotSize} ${y - dotSize} h ${size + 2 * dotSize} v ${size + 2 * dotSize} h ${-size - 2 * dotSize} z`);
|
|
341
355
|
}
|
|
342
356
|
});
|
|
343
357
|
}
|
|
@@ -347,7 +361,9 @@ class QRCornerSquare {
|
|
|
347
361
|
...args,
|
|
348
362
|
draw: () => {
|
|
349
363
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
350
|
-
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", svgPath`M ${x} ${y + 2.5 * dotSize} v ${2 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * dotSize} ${2.5 * dotSize} h ${2 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * dotSize} ${2.5 * -dotSize} v ${-2 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * -dotSize} ${2.5 * -dotSize} h ${-2 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * -dotSize} ${2.5 * dotSize} z M ${x + 2.5 * dotSize} ${y + dotSize} h ${2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * dotSize} ${1.5 * dotSize} v ${2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * -dotSize} ${1.5 * dotSize} h ${-2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * -dotSize} ${1.5 * -dotSize} v ${-2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * dotSize} ${1.5 * -dotSize} z`)
|
|
364
|
+
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", svgPath`M ${x} ${y + 2.5 * dotSize} v ${2 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * dotSize} ${2.5 * dotSize} h ${2 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * dotSize} ${2.5 * -dotSize} v ${-2 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * -dotSize} ${2.5 * -dotSize} h ${-2 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * -dotSize} ${2.5 * dotSize} z M ${x + 2.5 * dotSize} ${y + dotSize} h ${2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * dotSize} ${1.5 * dotSize} v ${2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * -dotSize} ${1.5 * dotSize} h ${-2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * -dotSize} ${1.5 * -dotSize} v ${-2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * dotSize} ${1.5 * -dotSize} z`),
|
|
365
|
+
this._fill = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
366
|
+
this._fill.setAttribute("clip-rule", "evenodd"), this._fill.setAttribute("d", svgPath`M ${x + 2.5 * dotSize} ${y + dotSize} h ${2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * dotSize} ${1.5 * dotSize} v ${2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * -dotSize} ${1.5 * dotSize} h ${-2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * -dotSize} ${1.5 * -dotSize} v ${-2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * dotSize} ${1.5 * -dotSize} z`);
|
|
351
367
|
}
|
|
352
368
|
});
|
|
353
369
|
}
|
|
@@ -357,7 +373,9 @@ class QRCornerSquare {
|
|
|
357
373
|
...args,
|
|
358
374
|
draw: () => {
|
|
359
375
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
360
|
-
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", svgPath`M ${x} ${y + 2.5 * dotSize} v ${2 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * dotSize} ${2.5 * dotSize} h ${4.5 * dotSize} v ${-4.5 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * -dotSize} ${2.5 * -dotSize} h ${-2 * dotSize} H ${x} z M ${x + 2.5 * dotSize} ${y + dotSize} h ${2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * dotSize} ${1.5 * dotSize} v ${3.5 * dotSize} h ${-3.5 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * -dotSize} ${1.5 * -dotSize} v ${-3.5 * dotSize} z`)
|
|
376
|
+
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", svgPath`M ${x} ${y + 2.5 * dotSize} v ${2 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * dotSize} ${2.5 * dotSize} h ${4.5 * dotSize} v ${-4.5 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * -dotSize} ${2.5 * -dotSize} h ${-2 * dotSize} H ${x} z M ${x + 2.5 * dotSize} ${y + dotSize} h ${2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * dotSize} ${1.5 * dotSize} v ${3.5 * dotSize} h ${-3.5 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * -dotSize} ${1.5 * -dotSize} v ${-3.5 * dotSize} z`),
|
|
377
|
+
this._fill = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
378
|
+
this._fill.setAttribute("clip-rule", "evenodd"), this._fill.setAttribute("d", svgPath`M ${x + .5 * dotSize} ${y - dotSize} h ${4 * dotSize} a ${3.5 * dotSize} ${3.5 * dotSize}, 0, 0, 1, ${3.5 * dotSize} ${3.5 * dotSize} v ${5.5 * dotSize} h ${-5.5 * dotSize} a ${3.5 * dotSize} ${3.5 * dotSize}, 0, 0, 1, ${3.5 * -dotSize} ${3.5 * -dotSize} v ${-5.5 * dotSize} z`);
|
|
361
379
|
}
|
|
362
380
|
});
|
|
363
381
|
}
|
|
@@ -367,7 +385,9 @@ class QRCornerSquare {
|
|
|
367
385
|
...args,
|
|
368
386
|
draw: () => {
|
|
369
387
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
370
|
-
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", svgPath`M ${x} ${y + 2.5 * dotSize} v ${2 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * dotSize} ${2.5 * dotSize} h ${4.5 * dotSize} v ${-4.5 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * -dotSize} ${2.5 * -dotSize} h ${-2 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * -dotSize} ${2.5 * dotSize} z M ${x + 2.5 * dotSize} ${y + dotSize} h ${2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * dotSize} ${1.5 * dotSize} v ${3.5 * dotSize} h ${-3.5 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * -dotSize} ${1.5 * -dotSize} v ${-2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * dotSize} ${1.5 * -dotSize} z`)
|
|
388
|
+
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", svgPath`M ${x} ${y + 2.5 * dotSize} v ${2 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * dotSize} ${2.5 * dotSize} h ${4.5 * dotSize} v ${-4.5 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * -dotSize} ${2.5 * -dotSize} h ${-2 * dotSize} a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${2.5 * -dotSize} ${2.5 * dotSize} z M ${x + 2.5 * dotSize} ${y + dotSize} h ${2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * dotSize} ${1.5 * dotSize} v ${3.5 * dotSize} h ${-3.5 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * -dotSize} ${1.5 * -dotSize} v ${-2 * dotSize} a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${1.5 * dotSize} ${1.5 * -dotSize} z`),
|
|
389
|
+
this._fill = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
390
|
+
this._fill.setAttribute("clip-rule", "evenodd"), this._fill.setAttribute("d", svgPath`M ${x + .5 * dotSize} ${y - dotSize} h ${4 * dotSize} a ${3.5 * dotSize} ${3.5 * dotSize}, 0, 0, 1, ${3.5 * dotSize} ${3.5 * dotSize} v ${5.5 * dotSize} h ${-5.5 * dotSize} a ${3.5 * dotSize} ${3.5 * dotSize}, 0, 0, 1, ${3.5 * -dotSize} ${3.5 * -dotSize} v ${-2 * dotSize} a ${3.5 * dotSize} ${3.5 * dotSize}, 0, 0, 1, ${3.5 * dotSize} ${3.5 * -dotSize} z`);
|
|
371
391
|
}
|
|
372
392
|
});
|
|
373
393
|
}
|
|
@@ -471,6 +491,10 @@ class QRDot {
|
|
|
471
491
|
drawFunction = this.drawSmallSquare;
|
|
472
492
|
break;
|
|
473
493
|
|
|
494
|
+
case DotType.tinySquare:
|
|
495
|
+
drawFunction = this.drawTinySquare;
|
|
496
|
+
break;
|
|
497
|
+
|
|
474
498
|
default:
|
|
475
499
|
drawFunction = this.drawSquare;
|
|
476
500
|
}
|
|
@@ -573,6 +597,14 @@ class QRDot {
|
|
|
573
597
|
rotation: 0
|
|
574
598
|
});
|
|
575
599
|
}
|
|
600
|
+
drawTinySquare({x, y, size}) {
|
|
601
|
+
this.basicSquare({
|
|
602
|
+
x: x + .35 * size,
|
|
603
|
+
y: y + .35 * size,
|
|
604
|
+
size: .3 * size,
|
|
605
|
+
rotation: 0
|
|
606
|
+
});
|
|
607
|
+
}
|
|
576
608
|
drawDiamond({x, y, size}) {
|
|
577
609
|
this.basicSquare({
|
|
578
610
|
x,
|
|
@@ -764,7 +796,7 @@ let browserImageTools = {
|
|
|
764
796
|
}))
|
|
765
797
|
};
|
|
766
798
|
|
|
767
|
-
let squareMask = [ [ 1, 1, 1, 1, 1, 1, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 1, 1, 1, 1, 1, 1 ] ], dotMask = [ [ 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 1, 1, 0, 0 ], [ 0, 0, 1, 1, 1, 0, 0 ], [ 0, 0, 1, 1, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0 ] ]
|
|
799
|
+
let squareMask = [ [ 1, 1, 1, 1, 1, 1, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 1, 1, 1, 1, 1, 1 ] ], dotMask = [ [ 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 1, 1, 0, 0 ], [ 0, 0, 1, 1, 1, 0, 0 ], [ 0, 0, 1, 1, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0 ] ];
|
|
768
800
|
|
|
769
801
|
class QRSVG {
|
|
770
802
|
get element() {
|
|
@@ -784,7 +816,9 @@ class QRSVG {
|
|
|
784
816
|
return this.options.height;
|
|
785
817
|
}
|
|
786
818
|
async drawQR(qr_size) {
|
|
787
|
-
let count = qr_size.getModuleCount()
|
|
819
|
+
let count = qr_size.getModuleCount();
|
|
820
|
+
var alignment_maxWidth_typeNumber = parseInt(((count - 17) / 4).toFixed(0), 10);
|
|
821
|
+
let dotSize = this.options.dotsOptions.size, drawImageSize = {
|
|
788
822
|
hideXDots: 0,
|
|
789
823
|
hideYDots: 0,
|
|
790
824
|
width: 0,
|
|
@@ -792,52 +826,65 @@ class QRSVG {
|
|
|
792
826
|
};
|
|
793
827
|
if (this.qr = qr_size, this.options.image) {
|
|
794
828
|
qr_size = await this.imageTools.getSize(this.options.image, this.options.imageOptions.crossOrigin);
|
|
795
|
-
let {imageOptions, errorCorrectionPercent} = this.options
|
|
796
|
-
|
|
797
|
-
|
|
829
|
+
let {imageOptions, errorCorrectionPercent} = this.options;
|
|
830
|
+
if (imageOptions.mode == ImageMode.background) {
|
|
831
|
+
alignment_maxWidth_typeNumber = this.options.width * imageOptions.imageSize;
|
|
832
|
+
var coverLevel_maxHeight = this.options.height * imageOptions.imageSize;
|
|
833
|
+
let {width, height} = qr_size;
|
|
834
|
+
height = height / width * alignment_maxWidth_typeNumber, width = alignment_maxWidth_typeNumber,
|
|
835
|
+
height > coverLevel_maxHeight && (width = width / height * coverLevel_maxHeight,
|
|
836
|
+
height = coverLevel_maxHeight), drawImageSize = {
|
|
837
|
+
hideXDots: 0,
|
|
838
|
+
hideYDots: 0,
|
|
839
|
+
width,
|
|
840
|
+
height
|
|
841
|
+
};
|
|
842
|
+
} else coverLevel_maxHeight = imageOptions.imageSize * errorCorrectionPercent, alignment_maxWidth_typeNumber = QRUtil.getPatternPosition(alignment_maxWidth_typeNumber),
|
|
843
|
+
drawImageSize = function({originalHeight, originalWidth, maxHiddenDots: JSCompiler_object_inline_x_16_hideMax_maxHiddenDots, maxHiddenAxisDots: JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper, dotSize, margin}) {
|
|
844
|
+
if (0 >= originalHeight || 0 >= originalWidth || 0 >= JSCompiler_object_inline_x_16_hideMax_maxHiddenDots || 0 >= dotSize || 4 * margin ** 2 > JSCompiler_object_inline_x_16_hideMax_maxHiddenDots) return {
|
|
798
845
|
height: 0,
|
|
799
846
|
width: 0,
|
|
800
847
|
hideYDots: 0,
|
|
801
848
|
hideXDots: 0
|
|
802
849
|
};
|
|
803
|
-
|
|
804
|
-
var
|
|
805
|
-
|
|
850
|
+
JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper && 0 == JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper % 2 && (JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = Math.max(1, JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper - 1));
|
|
851
|
+
var JSCompiler_object_inline_x_14_dimMax = Math.max(originalWidth, originalHeight), JSCompiler_object_inline_y_15_dimMin_hideMin = Math.min(originalWidth, originalHeight), lower_maxH_size = 0;
|
|
852
|
+
JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = (JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper || JSCompiler_object_inline_x_16_hideMax_maxHiddenDots) - 2 * margin;
|
|
806
853
|
do {
|
|
807
|
-
let size = lower_maxH_size + (
|
|
854
|
+
let size = lower_maxH_size + (JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper - lower_maxH_size) / 2, dotsMax = Math.max(1, Math.ceil(size + 2 * margin));
|
|
808
855
|
0 == dotsMax % 2 && dotsMax++;
|
|
809
|
-
let dotsMin = Math.max(1, Math.ceil(size *
|
|
810
|
-
0 == dotsMin % 2 && dotsMin++, dotsMax * dotsMin >
|
|
811
|
-
} while (.001 < Math.abs(lower_maxH_size -
|
|
812
|
-
return 0 == (
|
|
813
|
-
0 == (
|
|
814
|
-
originalWidth > originalHeight ?
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
(
|
|
818
|
-
|
|
856
|
+
let dotsMin = Math.max(1, Math.ceil(size * JSCompiler_object_inline_y_15_dimMin_hideMin / JSCompiler_object_inline_x_14_dimMax + 2 * margin));
|
|
857
|
+
0 == dotsMin % 2 && dotsMin++, dotsMax * dotsMin > JSCompiler_object_inline_x_16_hideMax_maxHiddenDots ? JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = size : lower_maxH_size = size;
|
|
858
|
+
} while (.001 < Math.abs(lower_maxH_size - JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper));
|
|
859
|
+
return 0 == (JSCompiler_object_inline_x_16_hideMax_maxHiddenDots = Math.max(1, Math.ceil(lower_maxH_size + 2 * margin))) % 2 && JSCompiler_object_inline_x_16_hideMax_maxHiddenDots++,
|
|
860
|
+
0 == (JSCompiler_object_inline_y_15_dimMin_hideMin = Math.max(1, Math.ceil(lower_maxH_size * JSCompiler_object_inline_y_15_dimMin_hideMin / JSCompiler_object_inline_x_14_dimMax + 2 * margin))) % 2 && JSCompiler_object_inline_y_15_dimMin_hideMin++,
|
|
861
|
+
originalWidth > originalHeight ? JSCompiler_object_inline_x_14_dimMax = JSCompiler_object_inline_x_16_hideMax_maxHiddenDots : (JSCompiler_object_inline_x_14_dimMax = JSCompiler_object_inline_y_15_dimMin_hideMin,
|
|
862
|
+
JSCompiler_object_inline_y_15_dimMin_hideMin = JSCompiler_object_inline_x_16_hideMax_maxHiddenDots),
|
|
863
|
+
JSCompiler_object_inline_x_16_hideMax_maxHiddenDots = JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = (JSCompiler_object_inline_x_14_dimMax - 2 * margin) * dotSize,
|
|
864
|
+
(JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper * originalHeight / originalWidth) > (lower_maxH_size = (JSCompiler_object_inline_y_15_dimMin_hideMin - 2 * margin) * dotSize) && (JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = lower_maxH_size,
|
|
865
|
+
JSCompiler_object_inline_x_16_hideMax_maxHiddenDots = lower_maxH_size * originalWidth / originalHeight),
|
|
819
866
|
{
|
|
820
|
-
height: Math.round(
|
|
821
|
-
width: Math.round(
|
|
822
|
-
hideYDots:
|
|
823
|
-
hideXDots:
|
|
867
|
+
height: Math.round(JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper + 2 * margin * dotSize),
|
|
868
|
+
width: Math.round(JSCompiler_object_inline_x_16_hideMax_maxHiddenDots + 2 * margin * dotSize),
|
|
869
|
+
hideYDots: JSCompiler_object_inline_y_15_dimMin_hideMin,
|
|
870
|
+
hideXDots: JSCompiler_object_inline_x_14_dimMax
|
|
824
871
|
};
|
|
825
872
|
}({
|
|
826
873
|
originalWidth: qr_size.width,
|
|
827
874
|
originalHeight: qr_size.height,
|
|
828
|
-
maxHiddenDots: Math.floor(
|
|
875
|
+
maxHiddenDots: Math.floor(coverLevel_maxHeight * (count * count - 192 - 2 * (count - 16) - 25 * alignment_maxWidth_typeNumber.length ** 2)),
|
|
829
876
|
maxHiddenAxisDots: count - 14,
|
|
830
877
|
dotSize,
|
|
831
878
|
margin: imageOptions.margin
|
|
832
879
|
});
|
|
833
880
|
}
|
|
834
|
-
this.
|
|
835
|
-
this.drawCorners(), this.options.image && 0 < drawImageSize.width && 0 < drawImageSize.height && await this.drawImage({
|
|
881
|
+
this.options.image && 0 < drawImageSize.width && 0 < drawImageSize.height && await this.drawImage({
|
|
836
882
|
width: drawImageSize.width,
|
|
837
883
|
height: drawImageSize.height,
|
|
838
884
|
count,
|
|
839
885
|
dotSize
|
|
840
|
-
})
|
|
886
|
+
}), this.drawBackground(), this.drawDots(((i, j) => !(this.options.imageOptions.mode == ImageMode.center && i >= (count - drawImageSize.hideXDots) / 2 && i < (count + drawImageSize.hideXDots) / 2 && j >= (count - drawImageSize.hideYDots) / 2 && j < (count + drawImageSize.hideYDots) / 2 || 8 > i && 8 > j || i >= count - 8 && 8 > j || j >= count - 8 && 8 > i))),
|
|
887
|
+
this.drawCorners();
|
|
841
888
|
}
|
|
842
889
|
drawBackground() {
|
|
843
890
|
let options = this.options;
|
|
@@ -860,47 +907,67 @@ class QRSVG {
|
|
|
860
907
|
this.backgroundMaskGroup.appendChild(element);
|
|
861
908
|
}
|
|
862
909
|
}
|
|
863
|
-
drawDots(
|
|
910
|
+
drawDots(alignment) {
|
|
864
911
|
if (!this.qr) throw "QR code is not defined";
|
|
865
|
-
let options = this.options
|
|
912
|
+
let options = this.options;
|
|
913
|
+
var count = this.qr.getModuleCount();
|
|
866
914
|
if (count > options.width || count > options.height) throw "The canvas is too small.";
|
|
867
|
-
var
|
|
915
|
+
var minSize_xFakeBeginning = Math.min(options.width, options.height);
|
|
868
916
|
let dotSize = this.options.dotsOptions.size;
|
|
869
|
-
var
|
|
870
|
-
let dot = new QRDot(options.dotsOptions.type, this.document);
|
|
871
|
-
[this.dotsMask, this.dotsMaskGroup] = this.createMask("mask-dot-color"), this.defs.appendChild(this.dotsMask)
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
let
|
|
885
|
-
|
|
886
|
-
fakeMatrix[i] = [];
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
917
|
+
var colorCount_xBeginning = Math.floor((options.width - count * dotSize) / 2), yBeginning_yFakeBeginning = Math.floor((options.height - count * dotSize) / 2);
|
|
918
|
+
let dot = new QRDot(options.dotsOptions.type, this.document), overlayDot = new QRDot(DotType.tinySquare, this.document), markerDot = new QRDot(DotType.square, this.document);
|
|
919
|
+
[this.dotsMask, this.dotsMaskGroup] = this.createMask("mask-dot-color"), this.defs.appendChild(this.dotsMask),
|
|
920
|
+
options.imageOptions.mode == ImageMode.background && ([this.lightDotsMask, this.lightDotsMaskGroup] = this.createMask("mask-light-dot-color"),
|
|
921
|
+
this.defs.appendChild(this.lightDotsMask));
|
|
922
|
+
var fakeCount_margin = 0;
|
|
923
|
+
let additionalDots = 0;
|
|
924
|
+
fakeCount_margin = count, options.shape === ShapeType.circle && (fakeCount_margin = this.options.backgroundOptions && this.options.backgroundOptions.margin || 0,
|
|
925
|
+
additionalDots = Math.floor((minSize_xFakeBeginning / dotSize - count - 2 * fakeCount_margin) / 2),
|
|
926
|
+
fakeCount_margin = count + 2 * additionalDots), minSize_xFakeBeginning = colorCount_xBeginning - additionalDots * dotSize,
|
|
927
|
+
yBeginning_yFakeBeginning -= additionalDots * dotSize, colorCount_xBeginning = count + 2 * additionalDots;
|
|
928
|
+
let fakeMatrix = Array(fakeCount_margin);
|
|
929
|
+
var center_jAlign = Math.floor(fakeCount_margin / 2);
|
|
930
|
+
for (let i = 0; i < fakeCount_margin; i++) {
|
|
931
|
+
fakeMatrix[i] = Array(fakeCount_margin);
|
|
932
|
+
for (let j = 0; j < fakeCount_margin; j++) if (i > additionalDots - 1 && i < fakeCount_margin - additionalDots && j > additionalDots - 1 && j < fakeCount_margin - additionalDots) {
|
|
933
|
+
let ii = i - additionalDots, jj = j - additionalDots;
|
|
934
|
+
alignment && !alignment(ii, jj) ? fakeMatrix[i][j] = void 0 : fakeMatrix[i][j] = !!this.qr.isDark(jj, ii);
|
|
935
|
+
} else options.shape === ShapeType.circle && Math.sqrt((i - center_jAlign) * (i - center_jAlign) + (j - center_jAlign) * (j - center_jAlign)) > center_jAlign ? fakeMatrix[i][j] = void 0 : i == additionalDots - 1 || i == fakeCount_margin - additionalDots || j == additionalDots - 1 || j == fakeCount_margin - additionalDots ? fakeMatrix[i][j] = (j == additionalDots - 1 && (i < additionalDots + 8 || i > fakeCount_margin - additionalDots - 9) || j == fakeCount_margin - additionalDots && i < additionalDots + 8 || i == additionalDots - 1 && (j < additionalDots + 8 || j > fakeCount_margin - additionalDots - 9) || i == fakeCount_margin - additionalDots && j < additionalDots + 8) && void 0 : this.lightDotsMask || (fakeMatrix[i][j] = this.qr.isDark(0 > j - 2 * additionalDots ? j : j >= count ? j - 2 * additionalDots : j - additionalDots, 0 > i - 2 * additionalDots ? i : i >= count ? i - 2 * additionalDots : i - additionalDots));
|
|
936
|
+
}
|
|
937
|
+
alignment = QRUtil.getPatternPosition((count - 17) / 4);
|
|
938
|
+
for (let i = 0; i < fakeCount_margin; i++) {
|
|
939
|
+
count = alignment.find((v => i - additionalDots > v - 3 && i - additionalDots < v + 3));
|
|
940
|
+
for (let j = 0; j < fakeCount_margin; j++) center_jAlign = alignment.find((v => j - additionalDots > v - 3 && j - additionalDots < v + 3)),
|
|
941
|
+
null != fakeMatrix[i][j] && (this.lightDotsMask && (dot = count && center_jAlign && (count != alignment[0] && center_jAlign != alignment[0] || center_jAlign != alignment[0] && center_jAlign != alignment[alignment.length - 1] || count != alignment[0] && count != alignment[alignment.length - 1]) ? markerDot : overlayDot),
|
|
942
|
+
fakeMatrix[i][j] ? (dot.draw({
|
|
943
|
+
x: minSize_xFakeBeginning + i * dotSize,
|
|
944
|
+
y: yBeginning_yFakeBeginning + j * dotSize,
|
|
945
|
+
size: dotSize,
|
|
946
|
+
getNeighbor: (xOffset, yOffset) => !0 === fakeMatrix[i + xOffset]?.[j + yOffset]
|
|
947
|
+
}), dot.element && this.dotsMaskGroup && this.dotsMaskGroup.appendChild(dot.element)) : this.lightDotsMask && (dot.draw({
|
|
948
|
+
x: minSize_xFakeBeginning + i * dotSize,
|
|
891
949
|
y: yBeginning_yFakeBeginning + j * dotSize,
|
|
892
950
|
size: dotSize,
|
|
893
|
-
getNeighbor: (xOffset, yOffset) =>
|
|
894
|
-
}), dot.element && this.
|
|
951
|
+
getNeighbor: (xOffset, yOffset) => !1 === fakeMatrix[i + xOffset]?.[j + yOffset]
|
|
952
|
+
}), dot.element && this.lightDotsMaskGroup && this.lightDotsMaskGroup.appendChild(dot.element)));
|
|
895
953
|
}
|
|
896
|
-
this.createColor({
|
|
954
|
+
this.lightDotsMask && this.createColor({
|
|
955
|
+
options: options.imageOptions.fill.gradient,
|
|
956
|
+
color: options.imageOptions.fill.color,
|
|
957
|
+
additionalRotation: 0,
|
|
958
|
+
x: minSize_xFakeBeginning - dotSize,
|
|
959
|
+
y: yBeginning_yFakeBeginning - dotSize,
|
|
960
|
+
height: (colorCount_xBeginning + 2) * dotSize,
|
|
961
|
+
width: (colorCount_xBeginning + 2) * dotSize,
|
|
962
|
+
name: "light-dot-color"
|
|
963
|
+
}), this.createColor({
|
|
897
964
|
options: options.dotsOptions?.gradient,
|
|
898
965
|
color: options.dotsOptions.color,
|
|
899
966
|
additionalRotation: 0,
|
|
900
|
-
x:
|
|
901
|
-
y:
|
|
902
|
-
height:
|
|
903
|
-
width:
|
|
967
|
+
x: minSize_xFakeBeginning,
|
|
968
|
+
y: yBeginning_yFakeBeginning,
|
|
969
|
+
height: colorCount_xBeginning * dotSize,
|
|
970
|
+
width: colorCount_xBeginning * dotSize,
|
|
904
971
|
name: "dot-color"
|
|
905
972
|
});
|
|
906
973
|
}
|
|
@@ -930,14 +997,26 @@ class QRSVG {
|
|
|
930
997
|
y,
|
|
931
998
|
size: cornersSquareSize,
|
|
932
999
|
rotation: dot
|
|
933
|
-
}), cornersDotMask_cornersSquare_dot.element && cornersSquareMaskGroup && cornersSquareMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.element)
|
|
1000
|
+
}), cornersDotMask_cornersSquare_dot.element && cornersSquareMaskGroup && cornersSquareMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.element),
|
|
1001
|
+
cornersDotMask_cornersSquare_dot.fill && this.lightDotsMaskGroup && this.lightDotsMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.fill); else {
|
|
934
1002
|
cornersDotMask_cornersSquare_dot = new QRDot(options.dotsOptions.type, this.document);
|
|
935
|
-
for (let i = 0; i < squareMask.length; i++) for (let j = 0; j < squareMask[i].length; j++) squareMask[i]?.[j]
|
|
1003
|
+
for (let i = 0; i < squareMask.length; i++) for (let j = 0; j < squareMask[i].length; j++) squareMask[i]?.[j] ? (cornersDotMask_cornersSquare_dot.draw({
|
|
936
1004
|
x: x + i * dotSize,
|
|
937
1005
|
y: y + j * dotSize,
|
|
938
1006
|
size: dotSize,
|
|
939
1007
|
getNeighbor: (xOffset, yOffset) => !!squareMask[i + xOffset]?.[j + yOffset]
|
|
940
|
-
}), cornersDotMask_cornersSquare_dot.element && cornersSquareMaskGroup && cornersSquareMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.element))
|
|
1008
|
+
}), cornersDotMask_cornersSquare_dot.element && cornersSquareMaskGroup && cornersSquareMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.element)) : this.lightDotsMask && !dotMask[i]?.[j] && (cornersDotMask_cornersSquare_dot.draw({
|
|
1009
|
+
x: x + i * dotSize,
|
|
1010
|
+
y: y + j * dotSize,
|
|
1011
|
+
size: dotSize,
|
|
1012
|
+
getNeighbor: (xOffset, yOffset) => !squareMask[i + xOffset]?.[j + yOffset] && !dotMask[i + xOffset]?.[j + yOffset]
|
|
1013
|
+
}), cornersDotMask_cornersSquare_dot.element && this.lightDotsMaskGroup && this.lightDotsMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.element));
|
|
1014
|
+
if (this.lightDotsMask) for (let i = -1; 8 > i; i++) for (let j = -1; 8 > j; j++) -1 != i && 7 != i && -1 != j && 7 != j || (cornersDotMask_cornersSquare_dot.draw({
|
|
1015
|
+
x: x + i * dotSize,
|
|
1016
|
+
y: y + j * dotSize,
|
|
1017
|
+
size: dotSize,
|
|
1018
|
+
getNeighbor: (ii, jj) => (jj = j + jj, -1 <= (ii = i + ii) && 7 >= ii && -1 <= jj && 7 >= jj && (-1 == ii || 7 == ii || -1 == jj || 7 == jj))
|
|
1019
|
+
}), cornersDotMask_cornersSquare_dot.element && this.lightDotsMaskGroup && this.lightDotsMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.element));
|
|
941
1020
|
}
|
|
942
1021
|
if ((options.cornersDotOptions?.gradient || options.cornersDotOptions?.color) && ([cornersDotMask_cornersSquare_dot, cornersDotMaskGroup_cornersSquareMask] = this.createMask(`mask-corners-dot-color-${column_cornersDot}-${row}`),
|
|
943
1022
|
this.defs.appendChild(cornersDotMask_cornersSquare_dot), this.createColor({
|
|
@@ -1023,6 +1102,8 @@ class QRSVG {
|
|
|
1023
1102
|
}
|
|
1024
1103
|
}
|
|
1025
1104
|
|
|
1105
|
+
Object.assign(QRCodeMinimal.stringToBytesFuncs, stringToBytes_UTF8);
|
|
1106
|
+
|
|
1026
1107
|
let QRCodeStyling$1 = class {
|
|
1027
1108
|
get size() {
|
|
1028
1109
|
if (this.qrSVG) return {
|
|
@@ -1036,9 +1117,9 @@ let QRCodeStyling$1 = class {
|
|
|
1036
1117
|
}
|
|
1037
1118
|
update(mode) {
|
|
1038
1119
|
this.container && (this.container.innerHTML = ""), this.options = mode ? sanitizeOptions(mergeDeep(this.options, mode)) : this.options,
|
|
1039
|
-
this.options.data && (this.options.stringToBytesFuncs && (Object.assign(
|
|
1040
|
-
delete this.options.stringToBytesFuncs), this.qr =
|
|
1041
|
-
|
|
1120
|
+
this.options.data && (this.options.stringToBytesFuncs && (Object.assign(QRCodeMinimal.stringToBytesFuncs, this.options.stringToBytesFuncs),
|
|
1121
|
+
delete this.options.stringToBytesFuncs), this.qr = new QRCodeMinimal(this.options.qrOptions.typeNumber, this.options.qrOptions.errorCorrectionLevel),
|
|
1122
|
+
mode = this.options.qrOptions.mode || function(data) {
|
|
1042
1123
|
switch (!0) {
|
|
1043
1124
|
case /^[0-9]*$/.test(data):
|
|
1044
1125
|
return Mode.numeric;
|
|
@@ -1052,9 +1133,8 @@ let QRCodeStyling$1 = class {
|
|
|
1052
1133
|
default:
|
|
1053
1134
|
return Mode.byte;
|
|
1054
1135
|
}
|
|
1055
|
-
}(this.options.data)
|
|
1056
|
-
|
|
1057
|
-
this.qr.make(), this.setupSvg(), this.append(this.container));
|
|
1136
|
+
}(this.options.data), this.qr.addData(this.options.data, mode), this.qr.make(),
|
|
1137
|
+
this.setupSvg(), this.append(this.container));
|
|
1058
1138
|
}
|
|
1059
1139
|
append(container) {
|
|
1060
1140
|
container && (this.qrSVG?.element && container.appendChild(this.qrSVG.element),
|
|
@@ -1074,12 +1154,13 @@ let QRCodeStyling$1 = class {
|
|
|
1074
1154
|
}
|
|
1075
1155
|
setupSvg() {
|
|
1076
1156
|
if (this.qr) {
|
|
1077
|
-
var
|
|
1078
|
-
|
|
1157
|
+
var moduleCount_size = this.qr.getModuleCount();
|
|
1158
|
+
this.options.imageOptions.mode == ImageMode.background && (moduleCount_size += 2),
|
|
1159
|
+
moduleCount_size = Math.ceil(this.options.dotsOptions.size * (Math.ceil((this.options.shape == ShapeType.circle ? Math.sqrt(2) : 1) * moduleCount_size) + 2 * (this.options.backgroundOptions && this.options.backgroundOptions.margin || 0))),
|
|
1079
1160
|
this.qrSVG = new QRSVG({
|
|
1080
1161
|
...this.options,
|
|
1081
|
-
width:
|
|
1082
|
-
height:
|
|
1162
|
+
width: moduleCount_size,
|
|
1163
|
+
height: moduleCount_size,
|
|
1083
1164
|
errorCorrectionPercent: ErrorCorrectionPercents[this.options.qrOptions.errorCorrectionLevel]
|
|
1084
1165
|
}), this.svgDrawingPromise = this.qrSVG.drawQR(this.qr).then((() => {
|
|
1085
1166
|
this.qrSVG?.element && this.extension?.(this.qrSVG.element, this.options);
|
|
@@ -1108,7 +1189,7 @@ class QRCodeStyling extends QRCodeStyling$1 {
|
|
|
1108
1189
|
data: buff
|
|
1109
1190
|
};
|
|
1110
1191
|
}
|
|
1111
|
-
let dom = (new DOMImplementation).createDocument(null,
|
|
1192
|
+
let dom = (new DOMImplementation).createDocument(null, ""), imageCache = new Map;
|
|
1112
1193
|
global.XMLSerializer = XMLSerializer$1, global.DOMParser = DOMParser$1, super({
|
|
1113
1194
|
...options,
|
|
1114
1195
|
document: options.document || dom,
|
|
@@ -1127,5 +1208,5 @@ class QRCodeStyling extends QRCodeStyling$1 {
|
|
|
1127
1208
|
|
|
1128
1209
|
var browserUtils = void 0;
|
|
1129
1210
|
|
|
1130
|
-
export { CornerDotType, CornerSquareType, DotType,
|
|
1211
|
+
export { CornerDotType, CornerSquareType, DotType, ErrorCorrectionPercents, FileExtension, GradientType, QRCodeStyling, ShapeType, browserUtils };
|
|
1131
1212
|
//# sourceMappingURL=qr-code-styling-node.js.map
|