@liquid-js/qr-code-styling 4.0.4 → 4.0.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 +141 -141
- package/lib/kanji.js.map +1 -1
- package/lib/qr-code-styling-node.js +764 -822
- package/lib/qr-code-styling-node.js.map +1 -1
- package/lib/qr-code-styling.js.map +1 -1
- package/package.json +1 -1
|
@@ -12,68 +12,49 @@ import { DOMImplementation, XMLSerializer as XMLSerializer$1, DOMParser as DOMPa
|
|
|
12
12
|
|
|
13
13
|
export { ErrorCorrectionLevel, Mode, TypeNumber } from "@liquid-js/qrcode-generator/lib/qrcode/QRCodeMinimal.js";
|
|
14
14
|
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
function
|
|
18
|
-
if (
|
|
19
|
-
let
|
|
20
|
-
return void 0 !==
|
|
21
|
-
|
|
22
|
-
}, Object.keys(
|
|
23
|
-
let
|
|
24
|
-
Array.isArray(
|
|
25
|
-
})),
|
|
15
|
+
let isObject = obj => !!obj && "object" == typeof obj && !Array.isArray(obj);
|
|
16
|
+
|
|
17
|
+
function mergeDeep(target, ...sources) {
|
|
18
|
+
if (!sources.length) return target;
|
|
19
|
+
let source = sources.shift();
|
|
20
|
+
return void 0 !== source && isObject(target) && isObject(source) ? (target = {
|
|
21
|
+
...target
|
|
22
|
+
}, Object.keys(source).forEach((key => {
|
|
23
|
+
let targetValue = target[key], sourceValue = source[key];
|
|
24
|
+
Array.isArray(targetValue) && Array.isArray(sourceValue) ? target[key] = sourceValue : isObject(targetValue) && isObject(sourceValue) ? target[key] = mergeDeep(Object.assign({}, targetValue), sourceValue) : target[key] = sourceValue;
|
|
25
|
+
})), mergeDeep(target, ...sources)) : target;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
if (!(
|
|
32
|
-
|
|
33
|
-
}).colorStops ||
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
offset: Number(
|
|
38
|
-
}))),
|
|
28
|
+
var GradientType, DotType, CornerDotType, CornerSquareType, ShapeType, ImageMode;
|
|
29
|
+
|
|
30
|
+
function sanitizeGradient(gradient_newGradient) {
|
|
31
|
+
if (!(gradient_newGradient = {
|
|
32
|
+
...gradient_newGradient
|
|
33
|
+
}).colorStops || !gradient_newGradient.colorStops.length) throw "Field 'colorStops' is required in gradient";
|
|
34
|
+
return gradient_newGradient.rotation = gradient_newGradient.rotation ? Number(gradient_newGradient.rotation) : 0,
|
|
35
|
+
gradient_newGradient.colorStops = gradient_newGradient.colorStops.map((colorStop => ({
|
|
36
|
+
...colorStop,
|
|
37
|
+
offset: Number(colorStop.offset)
|
|
38
|
+
}))), gradient_newGradient;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
$CornerDotType$jscomp$inline_4$$.classy = "classy", $CornerDotType$jscomp$inline_4$$.outpoint = "outpoint",
|
|
57
|
-
$CornerDotType$jscomp$inline_4$$.inpoint = "inpoint";
|
|
58
|
-
|
|
59
|
-
var $CornerSquareType$$, $CornerSquareType$jscomp$inline_6$$ = $CornerSquareType$$ || ($CornerSquareType$$ = {});
|
|
60
|
-
|
|
61
|
-
$CornerSquareType$jscomp$inline_6$$.dot = "dot", $CornerSquareType$jscomp$inline_6$$.square = "square",
|
|
62
|
-
$CornerSquareType$jscomp$inline_6$$.extraRounded = "extra-rounded", $CornerSquareType$jscomp$inline_6$$.classy = "classy",
|
|
63
|
-
$CornerSquareType$jscomp$inline_6$$.outpoint = "outpoint", $CornerSquareType$jscomp$inline_6$$.inpoint = "inpoint";
|
|
64
|
-
|
|
65
|
-
var $ShapeType$$, $ShapeType$jscomp$inline_8$$ = $ShapeType$$ || ($ShapeType$$ = {});
|
|
66
|
-
|
|
67
|
-
$ShapeType$jscomp$inline_8$$.square = "square", $ShapeType$jscomp$inline_8$$.circle = "circle";
|
|
68
|
-
|
|
69
|
-
var $ImageMode$$, $ImageMode$jscomp$inline_10$$ = $ImageMode$$ || ($ImageMode$$ = {});
|
|
70
|
-
|
|
71
|
-
$ImageMode$jscomp$inline_10$$.center = "center", $ImageMode$jscomp$inline_10$$.overlay = "overlay",
|
|
72
|
-
$ImageMode$jscomp$inline_10$$.background = "background";
|
|
73
|
-
|
|
74
|
-
let $defaultOptions$$ = {
|
|
41
|
+
(GradientType = GradientType || (GradientType = {})).radial = "radial", GradientType.linear = "linear",
|
|
42
|
+
(DotType = DotType || (DotType = {})).dot = "dot", DotType.randomDot = "random-dot",
|
|
43
|
+
DotType.rounded = "rounded", DotType.extraRounded = "extra-rounded", DotType.verticalLine = "vertical-line",
|
|
44
|
+
DotType.horizontalLine = "horizontal-line", DotType.classy = "classy", DotType.classyRounded = "classy-rounded",
|
|
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.overlay = "overlay", ImageMode.background = "background";
|
|
54
|
+
|
|
55
|
+
let defaultOptions = {
|
|
75
56
|
document: void 0,
|
|
76
|
-
shape:
|
|
57
|
+
shape: ShapeType.square,
|
|
77
58
|
width: void 0,
|
|
78
59
|
height: void 0,
|
|
79
60
|
data: "",
|
|
@@ -83,7 +64,7 @@ let $defaultOptions$$ = {
|
|
|
83
64
|
errorCorrectionLevel: ErrorCorrectionLevel.Q
|
|
84
65
|
},
|
|
85
66
|
imageOptions: {
|
|
86
|
-
mode:
|
|
67
|
+
mode: ImageMode.center,
|
|
87
68
|
imageSize: .4,
|
|
88
69
|
crossOrigin: void 0,
|
|
89
70
|
margin: 0,
|
|
@@ -92,779 +73,764 @@ let $defaultOptions$$ = {
|
|
|
92
73
|
}
|
|
93
74
|
},
|
|
94
75
|
dotsOptions: {
|
|
95
|
-
type:
|
|
76
|
+
type: DotType.square,
|
|
96
77
|
color: "#000",
|
|
97
78
|
size: 10
|
|
98
79
|
}
|
|
99
80
|
};
|
|
100
81
|
|
|
101
|
-
function
|
|
102
|
-
return (
|
|
103
|
-
|
|
82
|
+
function sanitizeOptions(newOptions_options) {
|
|
83
|
+
return (newOptions_options = {
|
|
84
|
+
...newOptions_options
|
|
104
85
|
}).imageOptions = {
|
|
105
|
-
|
|
106
|
-
imageSize: Math.min(1, Number(
|
|
107
|
-
margin: Number(
|
|
86
|
+
...newOptions_options.imageOptions,
|
|
87
|
+
imageSize: Math.min(1, Number(newOptions_options.imageOptions.imageSize)) || 1,
|
|
88
|
+
margin: Number(newOptions_options.imageOptions.margin),
|
|
108
89
|
fill: {
|
|
109
|
-
|
|
90
|
+
...newOptions_options.imageOptions.fill
|
|
110
91
|
}
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
$newOptions_options$jscomp$34$$;
|
|
92
|
+
}, newOptions_options.imageOptions.mode == ImageMode.overlay && (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 = {
|
|
95
|
+
...newOptions_options.dotsOptions
|
|
96
|
+
}, newOptions_options.dotsOptions.gradient && (newOptions_options.dotsOptions.gradient = sanitizeGradient(newOptions_options.dotsOptions.gradient)),
|
|
97
|
+
newOptions_options.dotsOptions.size = Math.round(Math.max(0, newOptions_options.dotsOptions.size) || 10),
|
|
98
|
+
newOptions_options.cornersSquareOptions && (newOptions_options.cornersSquareOptions = {
|
|
99
|
+
...newOptions_options.cornersSquareOptions
|
|
100
|
+
}, newOptions_options.cornersSquareOptions.gradient && (newOptions_options.cornersSquareOptions.gradient = sanitizeGradient(newOptions_options.cornersSquareOptions.gradient))),
|
|
101
|
+
newOptions_options.cornersDotOptions && (newOptions_options.cornersDotOptions = {
|
|
102
|
+
...newOptions_options.cornersDotOptions
|
|
103
|
+
}, newOptions_options.cornersDotOptions.gradient && (newOptions_options.cornersDotOptions.gradient = sanitizeGradient(newOptions_options.cornersDotOptions.gradient))),
|
|
104
|
+
newOptions_options.backgroundOptions && (newOptions_options.backgroundOptions = {
|
|
105
|
+
...newOptions_options.backgroundOptions
|
|
106
|
+
}, newOptions_options.backgroundOptions.gradient && (newOptions_options.backgroundOptions.gradient = sanitizeGradient(newOptions_options.backgroundOptions.gradient))),
|
|
107
|
+
newOptions_options.document || (newOptions_options.document = document), newOptions_options;
|
|
128
108
|
}
|
|
129
109
|
|
|
130
|
-
let
|
|
110
|
+
let ErrorCorrectionPercents = {
|
|
131
111
|
[ErrorCorrectionLevel.L]: .07,
|
|
132
112
|
[ErrorCorrectionLevel.M]: .15,
|
|
133
113
|
[ErrorCorrectionLevel.Q]: .25,
|
|
134
114
|
[ErrorCorrectionLevel.H]: .3
|
|
135
115
|
};
|
|
136
116
|
|
|
137
|
-
let
|
|
117
|
+
let rx = /\.?0+$/;
|
|
138
118
|
|
|
139
|
-
function
|
|
140
|
-
return
|
|
119
|
+
function numToAttr(value) {
|
|
120
|
+
return value.toFixed(7).replace(rx, "");
|
|
141
121
|
}
|
|
142
122
|
|
|
143
|
-
function
|
|
144
|
-
return
|
|
145
|
-
let
|
|
146
|
-
return
|
|
147
|
-
`${$t$$}${$p$$}${$v$$}`;
|
|
123
|
+
function svgPath(strings, ...values) {
|
|
124
|
+
return strings.reduce(((t, v, i) => {
|
|
125
|
+
let p = "";
|
|
126
|
+
return i && (p = values[i - 1]), "number" == typeof p && (p = numToAttr(p)), `${t}${p}${v}`;
|
|
148
127
|
}), "").trim().replace(/[\s\n\r]+/gim, " ");
|
|
149
128
|
}
|
|
150
129
|
|
|
151
|
-
class
|
|
130
|
+
class QRCornerDot {
|
|
152
131
|
get element() {
|
|
153
132
|
return this._element;
|
|
154
133
|
}
|
|
155
|
-
constructor(
|
|
156
|
-
this.type =
|
|
134
|
+
constructor(type, document) {
|
|
135
|
+
this.type = type, this.document = document;
|
|
157
136
|
}
|
|
158
|
-
draw(
|
|
159
|
-
let
|
|
137
|
+
draw(args) {
|
|
138
|
+
let drawFunction;
|
|
160
139
|
switch (this.type) {
|
|
161
|
-
case
|
|
162
|
-
|
|
140
|
+
case CornerDotType.square:
|
|
141
|
+
drawFunction = this.drawSquare;
|
|
163
142
|
break;
|
|
164
143
|
|
|
165
|
-
case
|
|
166
|
-
|
|
144
|
+
case CornerDotType.heart:
|
|
145
|
+
drawFunction = this.drawHeart;
|
|
167
146
|
break;
|
|
168
147
|
|
|
169
|
-
case
|
|
170
|
-
|
|
148
|
+
case CornerDotType.extraRounded:
|
|
149
|
+
drawFunction = this.drawRounded;
|
|
171
150
|
break;
|
|
172
151
|
|
|
173
|
-
case
|
|
174
|
-
|
|
152
|
+
case CornerDotType.classy:
|
|
153
|
+
drawFunction = this.drawClassy;
|
|
175
154
|
break;
|
|
176
155
|
|
|
177
|
-
case
|
|
178
|
-
|
|
156
|
+
case CornerDotType.inpoint:
|
|
157
|
+
drawFunction = this.drawInpoint;
|
|
179
158
|
break;
|
|
180
159
|
|
|
181
|
-
case
|
|
182
|
-
|
|
160
|
+
case CornerDotType.outpoint:
|
|
161
|
+
drawFunction = this.drawOutpoint;
|
|
183
162
|
break;
|
|
184
163
|
|
|
185
164
|
default:
|
|
186
|
-
|
|
165
|
+
drawFunction = this.drawDot;
|
|
187
166
|
}
|
|
188
|
-
|
|
167
|
+
drawFunction.call(this, args);
|
|
189
168
|
}
|
|
190
|
-
rotateFigure({x:
|
|
191
|
-
|
|
192
|
-
$draw$$(), this._element?.setAttribute("transform", `rotate(${$numToAttr$$(180 * $rotation$jscomp$3$$ / Math.PI)},${$cx_x$jscomp$88$$},${$cy_y$jscomp$73$$})`);
|
|
169
|
+
rotateFigure({x: cx_x, y: cy_y, size, rotation = 0, draw}) {
|
|
170
|
+
cx_x += size / 2, cy_y += size / 2, draw(), this._element?.setAttribute("transform", `rotate(${numToAttr(180 * rotation / Math.PI)},${cx_x},${cy_y})`);
|
|
193
171
|
}
|
|
194
|
-
basicDot(
|
|
195
|
-
let {size
|
|
172
|
+
basicDot(args) {
|
|
173
|
+
let {size, x, y} = args;
|
|
196
174
|
this.rotateFigure({
|
|
197
|
-
|
|
175
|
+
...args,
|
|
198
176
|
draw: () => {
|
|
199
177
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "circle"),
|
|
200
|
-
this._element.setAttribute("cx",
|
|
201
|
-
this._element.setAttribute("
|
|
202
|
-
this._element.setAttribute("r", $numToAttr$$($size$jscomp$22$$ / 2));
|
|
178
|
+
this._element.setAttribute("cx", numToAttr(x + size / 2)), this._element.setAttribute("cy", numToAttr(y + size / 2)),
|
|
179
|
+
this._element.setAttribute("r", numToAttr(size / 2));
|
|
203
180
|
}
|
|
204
181
|
});
|
|
205
182
|
}
|
|
206
|
-
basicSquare(
|
|
207
|
-
let {size
|
|
183
|
+
basicSquare(args) {
|
|
184
|
+
let {size, x, y} = args;
|
|
208
185
|
this.rotateFigure({
|
|
209
|
-
|
|
186
|
+
...args,
|
|
210
187
|
draw: () => {
|
|
211
188
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "rect"),
|
|
212
|
-
this._element.setAttribute("x",
|
|
213
|
-
this._element.setAttribute("width",
|
|
189
|
+
this._element.setAttribute("x", numToAttr(x)), this._element.setAttribute("y", numToAttr(y)),
|
|
190
|
+
this._element.setAttribute("width", numToAttr(size)), this._element.setAttribute("height", numToAttr(size));
|
|
214
191
|
}
|
|
215
192
|
});
|
|
216
193
|
}
|
|
217
|
-
basicHeart(
|
|
218
|
-
let {size
|
|
194
|
+
basicHeart(args) {
|
|
195
|
+
let {size, x, y} = args;
|
|
219
196
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
220
|
-
let
|
|
221
|
-
this._element.setAttribute("d", [ "M", 1, .3262506, "c", 0, .0383376, -.0064626, .0758377, -.0193751, .1125001, "s", -.0356247, .076875, -.0681248, .1206252, "c", -.0325, .0437499, -.0762503, .0931247, -.1312501, .1481249, "C", .7262502, .7625008, .6566626, .8279132, .5724999, .9037505, "L", .5, .9687506, "L", .4275001, .9037505, "C", .3433374, .8279132, .2737499, .7625005, .21875, .7075007, "C", .1637501, .6525008, .1199999, .6031258, .0874999, .5593758, "S", .0322876, .4754133, .0193751, .4387506, "S", 0, .3645881, 0, .3262506, "c", 0, -.0783374, .0262499, -.1437498, .07875, -.1962499, "s", .1179124, -.07875, .1962499, -.07875, "c", .0433376, 0, .0845875, .0091625, .12375, .0274999, "S", .4716623, .1229131, .5, .1562506, "c", .0283374, -.0333375, .0620874, -.0591625, .1012502, -.0775, "c", .0391627, -.0183375, .0804126, -.0274999, .12375, -.0274999, "c", .0783374, 0, .1437497, .0262499, .1962501, .07875, "S", 1, .2479131, 1, .3262506, "z" ].map((
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
let {size: $size$jscomp$25$$, x: $x$jscomp$92$$, y: $y$jscomp$77$$} = $args$jscomp$4$$;
|
|
197
|
+
let move = !1, i = 0;
|
|
198
|
+
this._element.setAttribute("d", [ "M", 1, .3262506, "c", 0, .0383376, -.0064626, .0758377, -.0193751, .1125001, "s", -.0356247, .076875, -.0681248, .1206252, "c", -.0325, .0437499, -.0762503, .0931247, -.1312501, .1481249, "C", .7262502, .7625008, .6566626, .8279132, .5724999, .9037505, "L", .5, .9687506, "L", .4275001, .9037505, "C", .3433374, .8279132, .2737499, .7625005, .21875, .7075007, "C", .1637501, .6525008, .1199999, .6031258, .0874999, .5593758, "S", .0322876, .4754133, .0193751, .4387506, "S", 0, .3645881, 0, .3262506, "c", 0, -.0783374, .0262499, -.1437498, .07875, -.1962499, "s", .1179124, -.07875, .1962499, -.07875, "c", .0433376, 0, .0845875, .0091625, .12375, .0274999, "S", .4716623, .1229131, .5, .1562506, "c", .0283374, -.0333375, .0620874, -.0591625, .1012502, -.0775, "c", .0391627, -.0183375, .0804126, -.0274999, .12375, -.0274999, "c", .0783374, 0, .1437497, .0262499, .1962501, .07875, "S", 1, .2479131, 1, .3262506, "z" ].map((v => "string" == typeof v ? (i = 0,
|
|
199
|
+
move = v.toUpperCase() == v, v) : (i++, v *= size, move && (v += 1 == i % 2 ? x : y),
|
|
200
|
+
numToAttr(v)))).join(" "));
|
|
201
|
+
}
|
|
202
|
+
basicRounded(args) {
|
|
203
|
+
let {size, x, y} = args;
|
|
228
204
|
this.rotateFigure({
|
|
229
|
-
|
|
205
|
+
...args,
|
|
230
206
|
draw: () => {
|
|
231
207
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "rect"),
|
|
232
|
-
this._element.setAttribute("x",
|
|
233
|
-
this._element.setAttribute("width",
|
|
234
|
-
this._element.setAttribute("rx",
|
|
208
|
+
this._element.setAttribute("x", numToAttr(x)), this._element.setAttribute("y", numToAttr(y)),
|
|
209
|
+
this._element.setAttribute("width", numToAttr(size)), this._element.setAttribute("height", numToAttr(size)),
|
|
210
|
+
this._element.setAttribute("rx", numToAttr(size / 4)), this._element.setAttribute("ry", numToAttr(size / 4));
|
|
235
211
|
}
|
|
236
212
|
});
|
|
237
213
|
}
|
|
238
|
-
basicClassy(
|
|
239
|
-
let {size
|
|
214
|
+
basicClassy(args) {
|
|
215
|
+
let {size, x, y} = args, dotSize = size / 7;
|
|
240
216
|
this.rotateFigure({
|
|
241
|
-
|
|
217
|
+
...args,
|
|
242
218
|
draw: () => {
|
|
243
219
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
244
|
-
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d",
|
|
220
|
+
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`);
|
|
245
221
|
}
|
|
246
222
|
});
|
|
247
223
|
}
|
|
248
|
-
basicInpoint(
|
|
249
|
-
let {size
|
|
224
|
+
basicInpoint(args) {
|
|
225
|
+
let {size, x, y} = args;
|
|
250
226
|
this.rotateFigure({
|
|
251
|
-
|
|
227
|
+
...args,
|
|
252
228
|
draw: () => {
|
|
253
229
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
254
|
-
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d",
|
|
230
|
+
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", svgPath`M ${x} ${y + size / 2} v ${size / 4} a ${size / 4}, ${size / 4} 0 0 0 ${size / 4}, ${size / 4} h ${size / 4 * 3} v ${-size / 4 * 3} a ${size / 4}, ${size / 4} 0 0 0 ${-size / 4}, ${-size / 4} h ${-size / 2} a ${size / 4}, ${size / 4} 0 0 0 ${-size / 4}, ${size / 4} z`);
|
|
255
231
|
}
|
|
256
232
|
});
|
|
257
233
|
}
|
|
258
|
-
drawDot({x
|
|
234
|
+
drawDot({x, y, size, rotation}) {
|
|
259
235
|
this.basicDot({
|
|
260
|
-
x
|
|
261
|
-
y
|
|
262
|
-
size
|
|
263
|
-
rotation
|
|
236
|
+
x,
|
|
237
|
+
y,
|
|
238
|
+
size,
|
|
239
|
+
rotation
|
|
264
240
|
});
|
|
265
241
|
}
|
|
266
|
-
drawSquare({x
|
|
242
|
+
drawSquare({x, y, size, rotation}) {
|
|
267
243
|
this.basicSquare({
|
|
268
|
-
x
|
|
269
|
-
y
|
|
270
|
-
size
|
|
271
|
-
rotation
|
|
244
|
+
x,
|
|
245
|
+
y,
|
|
246
|
+
size,
|
|
247
|
+
rotation
|
|
272
248
|
});
|
|
273
249
|
}
|
|
274
|
-
drawHeart({x
|
|
250
|
+
drawHeart({x, y, size, rotation}) {
|
|
275
251
|
this.basicHeart({
|
|
276
|
-
x
|
|
277
|
-
y
|
|
278
|
-
size
|
|
279
|
-
rotation
|
|
252
|
+
x,
|
|
253
|
+
y,
|
|
254
|
+
size,
|
|
255
|
+
rotation
|
|
280
256
|
});
|
|
281
257
|
}
|
|
282
|
-
drawRounded({x
|
|
258
|
+
drawRounded({x, y, size, rotation}) {
|
|
283
259
|
this.basicRounded({
|
|
284
|
-
x
|
|
285
|
-
y
|
|
286
|
-
size
|
|
287
|
-
rotation
|
|
260
|
+
x,
|
|
261
|
+
y,
|
|
262
|
+
size,
|
|
263
|
+
rotation
|
|
288
264
|
});
|
|
289
265
|
}
|
|
290
|
-
drawClassy({x
|
|
266
|
+
drawClassy({x, y, size, rotation}) {
|
|
291
267
|
this.basicClassy({
|
|
292
|
-
x
|
|
293
|
-
y
|
|
294
|
-
size
|
|
295
|
-
rotation
|
|
268
|
+
x,
|
|
269
|
+
y,
|
|
270
|
+
size,
|
|
271
|
+
rotation
|
|
296
272
|
});
|
|
297
273
|
}
|
|
298
|
-
drawInpoint({x
|
|
274
|
+
drawInpoint({x, y, size, rotation}) {
|
|
299
275
|
this.basicInpoint({
|
|
300
|
-
x
|
|
301
|
-
y
|
|
302
|
-
size
|
|
303
|
-
rotation
|
|
276
|
+
x,
|
|
277
|
+
y,
|
|
278
|
+
size,
|
|
279
|
+
rotation
|
|
304
280
|
});
|
|
305
281
|
}
|
|
306
|
-
drawOutpoint({x
|
|
282
|
+
drawOutpoint({x, y, size, rotation}) {
|
|
307
283
|
this.basicInpoint({
|
|
308
|
-
x
|
|
309
|
-
y
|
|
310
|
-
size
|
|
311
|
-
rotation: (
|
|
284
|
+
x,
|
|
285
|
+
y,
|
|
286
|
+
size,
|
|
287
|
+
rotation: (rotation || 0) + Math.PI
|
|
312
288
|
});
|
|
313
289
|
}
|
|
314
290
|
}
|
|
315
291
|
|
|
316
|
-
class
|
|
292
|
+
class QRCornerSquare {
|
|
317
293
|
get element() {
|
|
318
294
|
return this._element;
|
|
319
295
|
}
|
|
320
296
|
get fill() {
|
|
321
297
|
return this._fill;
|
|
322
298
|
}
|
|
323
|
-
constructor(
|
|
324
|
-
this.type =
|
|
299
|
+
constructor(type, document) {
|
|
300
|
+
this.type = type, this.document = document;
|
|
325
301
|
}
|
|
326
|
-
draw(
|
|
327
|
-
let
|
|
302
|
+
draw(args) {
|
|
303
|
+
let drawFunction;
|
|
328
304
|
switch (this.type) {
|
|
329
|
-
case
|
|
330
|
-
|
|
305
|
+
case CornerSquareType.square:
|
|
306
|
+
drawFunction = this.drawSquare;
|
|
331
307
|
break;
|
|
332
308
|
|
|
333
|
-
case
|
|
334
|
-
|
|
309
|
+
case CornerSquareType.extraRounded:
|
|
310
|
+
drawFunction = this.drawExtraRounded;
|
|
335
311
|
break;
|
|
336
312
|
|
|
337
|
-
case
|
|
338
|
-
|
|
313
|
+
case CornerSquareType.classy:
|
|
314
|
+
drawFunction = this.drawClassy;
|
|
339
315
|
break;
|
|
340
316
|
|
|
341
|
-
case
|
|
342
|
-
|
|
317
|
+
case CornerSquareType.outpoint:
|
|
318
|
+
drawFunction = this.drawOutpoint;
|
|
343
319
|
break;
|
|
344
320
|
|
|
345
|
-
case
|
|
346
|
-
|
|
321
|
+
case CornerSquareType.inpoint:
|
|
322
|
+
drawFunction = this.drawInpoint;
|
|
347
323
|
break;
|
|
348
324
|
|
|
349
325
|
default:
|
|
350
|
-
|
|
326
|
+
drawFunction = this.drawDot;
|
|
351
327
|
}
|
|
352
|
-
|
|
328
|
+
drawFunction.call(this, args);
|
|
353
329
|
}
|
|
354
|
-
rotateFigure({x:
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
this._fill?.setAttribute("transform", `rotate(${$numToAttr$$(180 * $rotation$jscomp$11$$ / Math.PI)},${$cx$jscomp$1_x$jscomp$102$$},${$cy$jscomp$1_y$jscomp$87$$})`);
|
|
330
|
+
rotateFigure({x: cx, y: cy, size, rotation = 0, draw}) {
|
|
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})`);
|
|
358
333
|
}
|
|
359
|
-
basicDot(
|
|
360
|
-
let {size
|
|
334
|
+
basicDot(args) {
|
|
335
|
+
let {size, x, y} = args, dotSize = size / 7;
|
|
361
336
|
this.rotateFigure({
|
|
362
|
-
|
|
337
|
+
...args,
|
|
363
338
|
draw: () => {
|
|
364
339
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
365
|
-
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d",
|
|
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`),
|
|
366
341
|
this._fill = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
367
|
-
this._fill.setAttribute("clip-rule", "evenodd"), this._fill.setAttribute("d",
|
|
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`);
|
|
368
343
|
}
|
|
369
344
|
});
|
|
370
345
|
}
|
|
371
|
-
basicSquare(
|
|
372
|
-
let {size
|
|
346
|
+
basicSquare(args) {
|
|
347
|
+
let {size, x, y} = args, dotSize = size / 7;
|
|
373
348
|
this.rotateFigure({
|
|
374
|
-
|
|
349
|
+
...args,
|
|
375
350
|
draw: () => {
|
|
376
351
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
377
|
-
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d",
|
|
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`),
|
|
378
353
|
this._fill = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
379
|
-
this._fill.setAttribute("clip-rule", "evenodd"), this._fill.setAttribute("d",
|
|
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`);
|
|
380
355
|
}
|
|
381
356
|
});
|
|
382
357
|
}
|
|
383
|
-
basicExtraRounded(
|
|
384
|
-
let {size
|
|
358
|
+
basicExtraRounded(args) {
|
|
359
|
+
let {size, x, y} = args, dotSize = size / 7;
|
|
385
360
|
this.rotateFigure({
|
|
386
|
-
|
|
361
|
+
...args,
|
|
387
362
|
draw: () => {
|
|
388
363
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
389
|
-
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d",
|
|
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`),
|
|
390
365
|
this._fill = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
391
|
-
this._fill.setAttribute("clip-rule", "evenodd"), this._fill.setAttribute("d",
|
|
366
|
+
this._fill.setAttribute("clip-rule", "evenodd"), this._fill.setAttribute("d", svgPath`M ${x - dotSize} ${y + 2.5 * dotSize} v ${2 * dotSize} a ${3.5 * dotSize} ${3.5 * dotSize}, 0, 0, 0, ${3.5 * dotSize} ${3.5 * dotSize} h ${2 * dotSize} a ${3.5 * dotSize} ${3.5 * dotSize}, 0, 0, 0, ${3.5 * dotSize} ${3.5 * -dotSize} v ${-2 * dotSize} a ${3.5 * dotSize} ${3.5 * dotSize}, 0, 0, 0, ${3.5 * -dotSize} ${3.5 * -dotSize} h ${-2 * dotSize} a ${3.5 * dotSize} ${3.5 * dotSize}, 0, 0, 0, ${3.5 * -dotSize} ${3.5 * dotSize} z`);
|
|
392
367
|
}
|
|
393
368
|
});
|
|
394
369
|
}
|
|
395
|
-
basicClassy(
|
|
396
|
-
let {size
|
|
370
|
+
basicClassy(args) {
|
|
371
|
+
let {size, x, y} = args, dotSize = size / 7;
|
|
397
372
|
this.rotateFigure({
|
|
398
|
-
|
|
373
|
+
...args,
|
|
399
374
|
draw: () => {
|
|
400
375
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
401
|
-
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d",
|
|
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`),
|
|
402
377
|
this._fill = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
403
|
-
this._fill.setAttribute("clip-rule", "evenodd"), this._fill.setAttribute("d",
|
|
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`);
|
|
404
379
|
}
|
|
405
380
|
});
|
|
406
381
|
}
|
|
407
|
-
basicInpoint(
|
|
408
|
-
let {size
|
|
382
|
+
basicInpoint(args) {
|
|
383
|
+
let {size, x, y} = args, dotSize = size / 7;
|
|
409
384
|
this.rotateFigure({
|
|
410
|
-
|
|
385
|
+
...args,
|
|
411
386
|
draw: () => {
|
|
412
387
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
413
|
-
this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d",
|
|
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`),
|
|
414
389
|
this._fill = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
415
|
-
this._fill.setAttribute("clip-rule", "evenodd"), this._fill.setAttribute("d",
|
|
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`);
|
|
416
391
|
}
|
|
417
392
|
});
|
|
418
393
|
}
|
|
419
|
-
drawDot({x
|
|
394
|
+
drawDot({x, y, size, rotation}) {
|
|
420
395
|
this.basicDot({
|
|
421
|
-
x
|
|
422
|
-
y
|
|
423
|
-
size
|
|
424
|
-
rotation
|
|
396
|
+
x,
|
|
397
|
+
y,
|
|
398
|
+
size,
|
|
399
|
+
rotation
|
|
425
400
|
});
|
|
426
401
|
}
|
|
427
|
-
drawSquare({x
|
|
402
|
+
drawSquare({x, y, size, rotation}) {
|
|
428
403
|
this.basicSquare({
|
|
429
|
-
x
|
|
430
|
-
y
|
|
431
|
-
size
|
|
432
|
-
rotation
|
|
404
|
+
x,
|
|
405
|
+
y,
|
|
406
|
+
size,
|
|
407
|
+
rotation
|
|
433
408
|
});
|
|
434
409
|
}
|
|
435
|
-
drawExtraRounded({x
|
|
410
|
+
drawExtraRounded({x, y, size, rotation}) {
|
|
436
411
|
this.basicExtraRounded({
|
|
437
|
-
x
|
|
438
|
-
y
|
|
439
|
-
size
|
|
440
|
-
rotation
|
|
412
|
+
x,
|
|
413
|
+
y,
|
|
414
|
+
size,
|
|
415
|
+
rotation
|
|
441
416
|
});
|
|
442
417
|
}
|
|
443
|
-
drawClassy({x
|
|
418
|
+
drawClassy({x, y, size, rotation}) {
|
|
444
419
|
this.basicClassy({
|
|
445
|
-
x
|
|
446
|
-
y
|
|
447
|
-
size
|
|
448
|
-
rotation
|
|
420
|
+
x,
|
|
421
|
+
y,
|
|
422
|
+
size,
|
|
423
|
+
rotation
|
|
449
424
|
});
|
|
450
425
|
}
|
|
451
|
-
drawInpoint({x
|
|
426
|
+
drawInpoint({x, y, size, rotation}) {
|
|
452
427
|
this.basicInpoint({
|
|
453
|
-
x
|
|
454
|
-
y
|
|
455
|
-
size
|
|
456
|
-
rotation
|
|
428
|
+
x,
|
|
429
|
+
y,
|
|
430
|
+
size,
|
|
431
|
+
rotation
|
|
457
432
|
});
|
|
458
433
|
}
|
|
459
|
-
drawOutpoint({x
|
|
434
|
+
drawOutpoint({x, y, size, rotation}) {
|
|
460
435
|
this.basicInpoint({
|
|
461
|
-
x
|
|
462
|
-
y
|
|
463
|
-
size
|
|
464
|
-
rotation: (
|
|
436
|
+
x,
|
|
437
|
+
y,
|
|
438
|
+
size,
|
|
439
|
+
rotation: (rotation || 0) + Math.PI
|
|
465
440
|
});
|
|
466
441
|
}
|
|
467
442
|
}
|
|
468
443
|
|
|
469
|
-
class
|
|
444
|
+
class QRDot {
|
|
470
445
|
get element() {
|
|
471
446
|
return this._element;
|
|
472
447
|
}
|
|
473
|
-
constructor(
|
|
474
|
-
this.type =
|
|
448
|
+
constructor(type, document) {
|
|
449
|
+
this.type = type, this.document = document;
|
|
475
450
|
}
|
|
476
|
-
draw(
|
|
477
|
-
let
|
|
451
|
+
draw(args) {
|
|
452
|
+
let drawFunction;
|
|
478
453
|
switch (this.type) {
|
|
479
|
-
case
|
|
480
|
-
|
|
454
|
+
case DotType.dot:
|
|
455
|
+
drawFunction = this.drawDot;
|
|
481
456
|
break;
|
|
482
457
|
|
|
483
|
-
case
|
|
484
|
-
|
|
458
|
+
case DotType.randomDot:
|
|
459
|
+
drawFunction = this.drawRandomDot;
|
|
485
460
|
break;
|
|
486
461
|
|
|
487
|
-
case
|
|
488
|
-
|
|
462
|
+
case DotType.classy:
|
|
463
|
+
drawFunction = this.drawClassy;
|
|
489
464
|
break;
|
|
490
465
|
|
|
491
|
-
case
|
|
492
|
-
|
|
466
|
+
case DotType.classyRounded:
|
|
467
|
+
drawFunction = this.drawClassyRounded;
|
|
493
468
|
break;
|
|
494
469
|
|
|
495
|
-
case
|
|
496
|
-
|
|
470
|
+
case DotType.rounded:
|
|
471
|
+
drawFunction = this.drawRounded;
|
|
497
472
|
break;
|
|
498
473
|
|
|
499
|
-
case
|
|
500
|
-
|
|
474
|
+
case DotType.verticalLine:
|
|
475
|
+
drawFunction = this.drawVerticalLine;
|
|
501
476
|
break;
|
|
502
477
|
|
|
503
|
-
case
|
|
504
|
-
|
|
478
|
+
case DotType.horizontalLine:
|
|
479
|
+
drawFunction = this.drawHorizontalLine;
|
|
505
480
|
break;
|
|
506
481
|
|
|
507
|
-
case
|
|
508
|
-
|
|
482
|
+
case DotType.extraRounded:
|
|
483
|
+
drawFunction = this.drawExtraRounded;
|
|
509
484
|
break;
|
|
510
485
|
|
|
511
|
-
case
|
|
512
|
-
|
|
486
|
+
case DotType.diamond:
|
|
487
|
+
drawFunction = this.drawDiamond;
|
|
513
488
|
break;
|
|
514
489
|
|
|
515
|
-
case
|
|
516
|
-
|
|
490
|
+
case DotType.smallSquare:
|
|
491
|
+
drawFunction = this.drawSmallSquare;
|
|
517
492
|
break;
|
|
518
493
|
|
|
519
|
-
case
|
|
520
|
-
|
|
494
|
+
case DotType.tinySquare:
|
|
495
|
+
drawFunction = this.drawTinySquare;
|
|
521
496
|
break;
|
|
522
497
|
|
|
523
498
|
default:
|
|
524
|
-
|
|
499
|
+
drawFunction = this.drawSquare;
|
|
525
500
|
}
|
|
526
|
-
|
|
501
|
+
drawFunction.call(this, args);
|
|
527
502
|
}
|
|
528
|
-
rotateFigure({x:
|
|
529
|
-
|
|
530
|
-
$draw$jscomp$2$$(), this._element?.setAttribute("transform", `rotate(${$numToAttr$$(180 * $rotation$jscomp$18$$ / Math.PI)},${$cx$jscomp$2_x$jscomp$114$$},${$cy$jscomp$2_y$jscomp$99$$})`);
|
|
503
|
+
rotateFigure({x: cx, y: cy, size, rotation = 0, draw}) {
|
|
504
|
+
cx += size / 2, cy += size / 2, draw(), this._element?.setAttribute("transform", `rotate(${numToAttr(180 * rotation / Math.PI)},${cx},${cy})`);
|
|
531
505
|
}
|
|
532
|
-
basicDot(
|
|
533
|
-
let {size
|
|
506
|
+
basicDot(args) {
|
|
507
|
+
let {size, x, y} = args;
|
|
534
508
|
this.rotateFigure({
|
|
535
|
-
|
|
509
|
+
...args,
|
|
536
510
|
draw: () => {
|
|
537
511
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "circle"),
|
|
538
|
-
this._element.setAttribute("cx",
|
|
539
|
-
this._element.setAttribute("
|
|
540
|
-
this._element.setAttribute("r", $numToAttr$$($size$jscomp$48$$ / 2));
|
|
512
|
+
this._element.setAttribute("cx", numToAttr(x + size / 2)), this._element.setAttribute("cy", numToAttr(y + size / 2)),
|
|
513
|
+
this._element.setAttribute("r", numToAttr(size / 2));
|
|
541
514
|
}
|
|
542
515
|
});
|
|
543
516
|
}
|
|
544
|
-
basicSquare(
|
|
545
|
-
let {size
|
|
517
|
+
basicSquare(args) {
|
|
518
|
+
let {size, x, y} = args;
|
|
546
519
|
this.rotateFigure({
|
|
547
|
-
|
|
520
|
+
...args,
|
|
548
521
|
draw: () => {
|
|
549
522
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "rect"),
|
|
550
|
-
this._element.setAttribute("x",
|
|
551
|
-
this._element.setAttribute("width",
|
|
523
|
+
this._element.setAttribute("x", numToAttr(x)), this._element.setAttribute("y", numToAttr(y)),
|
|
524
|
+
this._element.setAttribute("width", numToAttr(size)), this._element.setAttribute("height", numToAttr(size));
|
|
552
525
|
}
|
|
553
526
|
});
|
|
554
527
|
}
|
|
555
|
-
basicSideRounded(
|
|
556
|
-
let {size
|
|
528
|
+
basicSideRounded(args) {
|
|
529
|
+
let {size, x, y} = args;
|
|
557
530
|
this.rotateFigure({
|
|
558
|
-
|
|
531
|
+
...args,
|
|
559
532
|
draw: () => {
|
|
560
533
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
561
|
-
this._element.setAttribute("d",
|
|
534
|
+
this._element.setAttribute("d", svgPath`M ${x} ${y} v ${size} h ${size / 2} a ${size / 2} ${size / 2}, 0, 0, 0, 0 ${-size} z`);
|
|
562
535
|
}
|
|
563
536
|
});
|
|
564
537
|
}
|
|
565
|
-
basicCornerRounded(
|
|
566
|
-
let {size
|
|
538
|
+
basicCornerRounded(args) {
|
|
539
|
+
let {size, x, y} = args;
|
|
567
540
|
this.rotateFigure({
|
|
568
|
-
|
|
541
|
+
...args,
|
|
569
542
|
draw: () => {
|
|
570
543
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
571
|
-
this._element.setAttribute("d",
|
|
544
|
+
this._element.setAttribute("d", svgPath`M ${x} ${y} v ${size} h ${size} v ${-size / 2} a ${size / 2} ${size / 2}, 0, 0, 0, ${-size / 2} ${-size / 2} z`);
|
|
572
545
|
}
|
|
573
546
|
});
|
|
574
547
|
}
|
|
575
|
-
basicCornerExtraRounded(
|
|
576
|
-
let {size
|
|
548
|
+
basicCornerExtraRounded(args) {
|
|
549
|
+
let {size, x, y} = args;
|
|
577
550
|
this.rotateFigure({
|
|
578
|
-
|
|
551
|
+
...args,
|
|
579
552
|
draw: () => {
|
|
580
553
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
581
|
-
this._element.setAttribute("d",
|
|
554
|
+
this._element.setAttribute("d", svgPath`M ${x} ${y} v ${size} h ${size} a ${size} ${size}, 0, 0, 0, ${-size} ${-size} z`);
|
|
582
555
|
}
|
|
583
556
|
});
|
|
584
557
|
}
|
|
585
|
-
basicCornersRounded(
|
|
586
|
-
let {size
|
|
558
|
+
basicCornersRounded(args) {
|
|
559
|
+
let {size, x, y} = args;
|
|
587
560
|
this.rotateFigure({
|
|
588
|
-
|
|
561
|
+
...args,
|
|
589
562
|
draw: () => {
|
|
590
563
|
this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
|
|
591
|
-
this._element.setAttribute("d",
|
|
564
|
+
this._element.setAttribute("d", svgPath`M ${x} ${y} v ${size / 2} a ${size / 2} ${size / 2}, 0, 0, 0, ${size / 2} ${size / 2} h ${size / 2} v ${-size / 2} a ${size / 2} ${size / 2}, 0, 0, 0, ${-size / 2} ${-size / 2} z`);
|
|
592
565
|
}
|
|
593
566
|
});
|
|
594
567
|
}
|
|
595
|
-
drawDot({x
|
|
568
|
+
drawDot({x, y, size}) {
|
|
596
569
|
this.basicDot({
|
|
597
|
-
x
|
|
598
|
-
y
|
|
599
|
-
size
|
|
570
|
+
x,
|
|
571
|
+
y,
|
|
572
|
+
size,
|
|
600
573
|
rotation: 0
|
|
601
574
|
});
|
|
602
575
|
}
|
|
603
|
-
drawRandomDot({x
|
|
576
|
+
drawRandomDot({x, y, size}) {
|
|
604
577
|
this.basicDot({
|
|
605
|
-
x
|
|
606
|
-
y
|
|
607
|
-
size:
|
|
578
|
+
x,
|
|
579
|
+
y,
|
|
580
|
+
size: size * (.25 * Math.random() + .75),
|
|
608
581
|
rotation: 0
|
|
609
582
|
});
|
|
610
583
|
}
|
|
611
|
-
drawSquare({x
|
|
584
|
+
drawSquare({x, y, size}) {
|
|
612
585
|
this.basicSquare({
|
|
613
|
-
x
|
|
614
|
-
y
|
|
615
|
-
size
|
|
586
|
+
x,
|
|
587
|
+
y,
|
|
588
|
+
size,
|
|
616
589
|
rotation: 0
|
|
617
590
|
});
|
|
618
591
|
}
|
|
619
|
-
drawSmallSquare({x
|
|
592
|
+
drawSmallSquare({x, y, size}) {
|
|
620
593
|
this.basicSquare({
|
|
621
|
-
x:
|
|
622
|
-
y:
|
|
623
|
-
size: .7 *
|
|
594
|
+
x: x + .15 * size,
|
|
595
|
+
y: y + .15 * size,
|
|
596
|
+
size: .7 * size,
|
|
624
597
|
rotation: 0
|
|
625
598
|
});
|
|
626
599
|
}
|
|
627
|
-
drawTinySquare({x
|
|
600
|
+
drawTinySquare({x, y, size}) {
|
|
628
601
|
this.basicSquare({
|
|
629
|
-
x:
|
|
630
|
-
y:
|
|
631
|
-
size: .3 *
|
|
602
|
+
x: x + .35 * size,
|
|
603
|
+
y: y + .35 * size,
|
|
604
|
+
size: .3 * size,
|
|
632
605
|
rotation: 0
|
|
633
606
|
});
|
|
634
607
|
}
|
|
635
|
-
drawDiamond({x
|
|
608
|
+
drawDiamond({x, y, size}) {
|
|
636
609
|
this.basicSquare({
|
|
637
|
-
x
|
|
638
|
-
y
|
|
639
|
-
size
|
|
610
|
+
x,
|
|
611
|
+
y,
|
|
612
|
+
size,
|
|
640
613
|
rotation: Math.PI / 4
|
|
641
614
|
});
|
|
642
615
|
}
|
|
643
|
-
drawRounded({x
|
|
644
|
-
var
|
|
645
|
-
let
|
|
646
|
-
var
|
|
647
|
-
0 ===
|
|
648
|
-
x
|
|
649
|
-
y
|
|
650
|
-
size
|
|
616
|
+
drawRounded({x, y, size, getNeighbor: bottomNeighbor_getNeighbor}) {
|
|
617
|
+
var leftNeighbor_rotation = bottomNeighbor_getNeighbor ? +bottomNeighbor_getNeighbor(-1, 0) : 0;
|
|
618
|
+
let rightNeighbor = bottomNeighbor_getNeighbor ? +bottomNeighbor_getNeighbor(1, 0) : 0, topNeighbor = bottomNeighbor_getNeighbor ? +bottomNeighbor_getNeighbor(0, -1) : 0;
|
|
619
|
+
var neighborsCount_rotation = leftNeighbor_rotation + rightNeighbor + topNeighbor + (bottomNeighbor_getNeighbor = bottomNeighbor_getNeighbor ? +bottomNeighbor_getNeighbor(0, 1) : 0);
|
|
620
|
+
0 === neighborsCount_rotation ? this.basicDot({
|
|
621
|
+
x,
|
|
622
|
+
y,
|
|
623
|
+
size,
|
|
651
624
|
rotation: 0
|
|
652
|
-
}) : 2 <
|
|
653
|
-
x
|
|
654
|
-
y
|
|
655
|
-
size
|
|
625
|
+
}) : 2 < neighborsCount_rotation || leftNeighbor_rotation && rightNeighbor || topNeighbor && bottomNeighbor_getNeighbor ? this.basicSquare({
|
|
626
|
+
x,
|
|
627
|
+
y,
|
|
628
|
+
size,
|
|
656
629
|
rotation: 0
|
|
657
|
-
}) : 2 ===
|
|
658
|
-
$leftNeighbor_rotation$jscomp$20$$ && $topNeighbor$$ ? $neighborsCount_rotation$jscomp$19$$ = Math.PI / 2 : $topNeighbor$$ && $rightNeighbor$$ ? $neighborsCount_rotation$jscomp$19$$ = Math.PI : $rightNeighbor$$ && $bottomNeighbor_getNeighbor$$ && ($neighborsCount_rotation$jscomp$19$$ = -Math.PI / 2),
|
|
630
|
+
}) : 2 === neighborsCount_rotation ? (neighborsCount_rotation = 0, leftNeighbor_rotation && topNeighbor ? neighborsCount_rotation = Math.PI / 2 : topNeighbor && rightNeighbor ? neighborsCount_rotation = Math.PI : rightNeighbor && bottomNeighbor_getNeighbor && (neighborsCount_rotation = -Math.PI / 2),
|
|
659
631
|
this.basicCornerRounded({
|
|
660
|
-
x
|
|
661
|
-
y
|
|
662
|
-
size
|
|
663
|
-
rotation:
|
|
664
|
-
})) : 1 ===
|
|
665
|
-
$topNeighbor$$ ? $leftNeighbor_rotation$jscomp$20$$ = Math.PI / 2 : $rightNeighbor$$ ? $leftNeighbor_rotation$jscomp$20$$ = Math.PI : $bottomNeighbor_getNeighbor$$ && ($leftNeighbor_rotation$jscomp$20$$ = -Math.PI / 2),
|
|
632
|
+
x,
|
|
633
|
+
y,
|
|
634
|
+
size,
|
|
635
|
+
rotation: neighborsCount_rotation
|
|
636
|
+
})) : 1 === neighborsCount_rotation && (leftNeighbor_rotation = 0, topNeighbor ? leftNeighbor_rotation = Math.PI / 2 : rightNeighbor ? leftNeighbor_rotation = Math.PI : bottomNeighbor_getNeighbor && (leftNeighbor_rotation = -Math.PI / 2),
|
|
666
637
|
this.basicSideRounded({
|
|
667
|
-
x
|
|
668
|
-
y
|
|
669
|
-
size
|
|
670
|
-
rotation:
|
|
638
|
+
x,
|
|
639
|
+
y,
|
|
640
|
+
size,
|
|
641
|
+
rotation: leftNeighbor_rotation
|
|
671
642
|
}));
|
|
672
643
|
}
|
|
673
|
-
drawVerticalLine({x
|
|
674
|
-
let
|
|
675
|
-
0 ===
|
|
676
|
-
x
|
|
677
|
-
y
|
|
678
|
-
size
|
|
644
|
+
drawVerticalLine({x, y, size, getNeighbor: bottomNeighbor}) {
|
|
645
|
+
let leftNeighbor = bottomNeighbor ? +bottomNeighbor(-1, 0) : 0, rightNeighbor = bottomNeighbor ? +bottomNeighbor(1, 0) : 0, topNeighbor = bottomNeighbor ? +bottomNeighbor(0, -1) : 0;
|
|
646
|
+
0 === leftNeighbor + rightNeighbor + topNeighbor + (bottomNeighbor = bottomNeighbor ? +bottomNeighbor(0, 1) : 0) || leftNeighbor && !topNeighbor && !bottomNeighbor || rightNeighbor && !topNeighbor && !bottomNeighbor ? this.basicDot({
|
|
647
|
+
x,
|
|
648
|
+
y,
|
|
649
|
+
size,
|
|
679
650
|
rotation: 0
|
|
680
|
-
}) :
|
|
681
|
-
x
|
|
682
|
-
y
|
|
683
|
-
size
|
|
651
|
+
}) : topNeighbor && bottomNeighbor ? this.basicSquare({
|
|
652
|
+
x,
|
|
653
|
+
y,
|
|
654
|
+
size,
|
|
684
655
|
rotation: 0
|
|
685
|
-
}) :
|
|
686
|
-
x
|
|
687
|
-
y
|
|
688
|
-
size
|
|
656
|
+
}) : topNeighbor && !bottomNeighbor ? this.basicSideRounded({
|
|
657
|
+
x,
|
|
658
|
+
y,
|
|
659
|
+
size,
|
|
689
660
|
rotation: Math.PI / 2
|
|
690
|
-
}) :
|
|
691
|
-
x
|
|
692
|
-
y
|
|
693
|
-
size
|
|
661
|
+
}) : bottomNeighbor && !topNeighbor && this.basicSideRounded({
|
|
662
|
+
x,
|
|
663
|
+
y,
|
|
664
|
+
size,
|
|
694
665
|
rotation: -Math.PI / 2
|
|
695
666
|
});
|
|
696
667
|
}
|
|
697
|
-
drawHorizontalLine({x
|
|
698
|
-
let
|
|
699
|
-
0 ===
|
|
700
|
-
x
|
|
701
|
-
y
|
|
702
|
-
size
|
|
668
|
+
drawHorizontalLine({x, y, size, getNeighbor: bottomNeighbor}) {
|
|
669
|
+
let leftNeighbor = bottomNeighbor ? +bottomNeighbor(-1, 0) : 0, rightNeighbor = bottomNeighbor ? +bottomNeighbor(1, 0) : 0, topNeighbor = bottomNeighbor ? +bottomNeighbor(0, -1) : 0;
|
|
670
|
+
0 === leftNeighbor + rightNeighbor + topNeighbor + (bottomNeighbor = bottomNeighbor ? +bottomNeighbor(0, 1) : 0) || topNeighbor && !leftNeighbor && !rightNeighbor || bottomNeighbor && !leftNeighbor && !rightNeighbor ? this.basicDot({
|
|
671
|
+
x,
|
|
672
|
+
y,
|
|
673
|
+
size,
|
|
703
674
|
rotation: 0
|
|
704
|
-
}) :
|
|
705
|
-
x
|
|
706
|
-
y
|
|
707
|
-
size
|
|
675
|
+
}) : leftNeighbor && rightNeighbor ? this.basicSquare({
|
|
676
|
+
x,
|
|
677
|
+
y,
|
|
678
|
+
size,
|
|
708
679
|
rotation: 0
|
|
709
|
-
}) :
|
|
710
|
-
x
|
|
711
|
-
y
|
|
712
|
-
size
|
|
680
|
+
}) : leftNeighbor && !rightNeighbor ? this.basicSideRounded({
|
|
681
|
+
x,
|
|
682
|
+
y,
|
|
683
|
+
size,
|
|
713
684
|
rotation: 0
|
|
714
|
-
}) :
|
|
715
|
-
x
|
|
716
|
-
y
|
|
717
|
-
size
|
|
685
|
+
}) : rightNeighbor && !leftNeighbor && this.basicSideRounded({
|
|
686
|
+
x,
|
|
687
|
+
y,
|
|
688
|
+
size,
|
|
718
689
|
rotation: Math.PI
|
|
719
690
|
});
|
|
720
691
|
}
|
|
721
|
-
drawExtraRounded({x
|
|
722
|
-
var
|
|
723
|
-
let
|
|
724
|
-
var
|
|
725
|
-
0 ===
|
|
726
|
-
x
|
|
727
|
-
y
|
|
728
|
-
size
|
|
692
|
+
drawExtraRounded({x, y, size, getNeighbor: bottomNeighbor}) {
|
|
693
|
+
var leftNeighbor = bottomNeighbor ? +bottomNeighbor(-1, 0) : 0;
|
|
694
|
+
let rightNeighbor = bottomNeighbor ? +bottomNeighbor(1, 0) : 0, topNeighbor = bottomNeighbor ? +bottomNeighbor(0, -1) : 0;
|
|
695
|
+
var neighborsCount = leftNeighbor + rightNeighbor + topNeighbor + (bottomNeighbor = bottomNeighbor ? +bottomNeighbor(0, 1) : 0);
|
|
696
|
+
0 === neighborsCount ? this.basicDot({
|
|
697
|
+
x,
|
|
698
|
+
y,
|
|
699
|
+
size,
|
|
729
700
|
rotation: 0
|
|
730
|
-
}) : 2 <
|
|
731
|
-
x
|
|
732
|
-
y
|
|
733
|
-
size
|
|
701
|
+
}) : 2 < neighborsCount || leftNeighbor && rightNeighbor || topNeighbor && bottomNeighbor ? this.basicSquare({
|
|
702
|
+
x,
|
|
703
|
+
y,
|
|
704
|
+
size,
|
|
734
705
|
rotation: 0
|
|
735
|
-
}) : 2 ===
|
|
736
|
-
$leftNeighbor$jscomp$3_rotation$jscomp$26$$ && $topNeighbor$jscomp$3$$ ? $neighborsCount$jscomp$3_rotation$jscomp$25$$ = Math.PI / 2 : $topNeighbor$jscomp$3$$ && $rightNeighbor$jscomp$3$$ ? $neighborsCount$jscomp$3_rotation$jscomp$25$$ = Math.PI : $rightNeighbor$jscomp$3$$ && $bottomNeighbor$jscomp$3_getNeighbor$jscomp$3$$ && ($neighborsCount$jscomp$3_rotation$jscomp$25$$ = -Math.PI / 2),
|
|
706
|
+
}) : 2 === neighborsCount ? (neighborsCount = 0, leftNeighbor && topNeighbor ? neighborsCount = Math.PI / 2 : topNeighbor && rightNeighbor ? neighborsCount = Math.PI : rightNeighbor && bottomNeighbor && (neighborsCount = -Math.PI / 2),
|
|
737
707
|
this.basicCornerExtraRounded({
|
|
738
|
-
x
|
|
739
|
-
y
|
|
740
|
-
size
|
|
741
|
-
rotation:
|
|
742
|
-
})) : 1 ===
|
|
743
|
-
$topNeighbor$jscomp$3$$ ? $leftNeighbor$jscomp$3_rotation$jscomp$26$$ = Math.PI / 2 : $rightNeighbor$jscomp$3$$ ? $leftNeighbor$jscomp$3_rotation$jscomp$26$$ = Math.PI : $bottomNeighbor$jscomp$3_getNeighbor$jscomp$3$$ && ($leftNeighbor$jscomp$3_rotation$jscomp$26$$ = -Math.PI / 2),
|
|
708
|
+
x,
|
|
709
|
+
y,
|
|
710
|
+
size,
|
|
711
|
+
rotation: neighborsCount
|
|
712
|
+
})) : 1 === neighborsCount && (leftNeighbor = 0, topNeighbor ? leftNeighbor = Math.PI / 2 : rightNeighbor ? leftNeighbor = Math.PI : bottomNeighbor && (leftNeighbor = -Math.PI / 2),
|
|
744
713
|
this.basicSideRounded({
|
|
745
|
-
x
|
|
746
|
-
y
|
|
747
|
-
size
|
|
748
|
-
rotation:
|
|
714
|
+
x,
|
|
715
|
+
y,
|
|
716
|
+
size,
|
|
717
|
+
rotation: leftNeighbor
|
|
749
718
|
}));
|
|
750
719
|
}
|
|
751
|
-
drawClassy({x
|
|
752
|
-
let
|
|
753
|
-
0 ===
|
|
754
|
-
x
|
|
755
|
-
y
|
|
756
|
-
size
|
|
720
|
+
drawClassy({x, y, size, getNeighbor: bottomNeighbor}) {
|
|
721
|
+
let leftNeighbor = bottomNeighbor ? +bottomNeighbor(-1, 0) : 0, rightNeighbor = bottomNeighbor ? +bottomNeighbor(1, 0) : 0, topNeighbor = bottomNeighbor ? +bottomNeighbor(0, -1) : 0;
|
|
722
|
+
0 === leftNeighbor + rightNeighbor + topNeighbor + (bottomNeighbor = bottomNeighbor ? +bottomNeighbor(0, 1) : 0) ? this.basicCornersRounded({
|
|
723
|
+
x,
|
|
724
|
+
y,
|
|
725
|
+
size,
|
|
757
726
|
rotation: Math.PI / 2
|
|
758
|
-
}) :
|
|
759
|
-
x
|
|
760
|
-
y
|
|
761
|
-
size
|
|
727
|
+
}) : leftNeighbor || topNeighbor ? rightNeighbor || bottomNeighbor ? this.basicSquare({
|
|
728
|
+
x,
|
|
729
|
+
y,
|
|
730
|
+
size,
|
|
762
731
|
rotation: 0
|
|
763
732
|
}) : this.basicCornerRounded({
|
|
764
|
-
x
|
|
765
|
-
y
|
|
766
|
-
size
|
|
733
|
+
x,
|
|
734
|
+
y,
|
|
735
|
+
size,
|
|
767
736
|
rotation: Math.PI / 2
|
|
768
737
|
}) : this.basicCornerRounded({
|
|
769
|
-
x
|
|
770
|
-
y
|
|
771
|
-
size
|
|
738
|
+
x,
|
|
739
|
+
y,
|
|
740
|
+
size,
|
|
772
741
|
rotation: -Math.PI / 2
|
|
773
742
|
});
|
|
774
743
|
}
|
|
775
|
-
drawClassyRounded({x
|
|
776
|
-
let
|
|
777
|
-
0 ===
|
|
778
|
-
x
|
|
779
|
-
y
|
|
780
|
-
size
|
|
744
|
+
drawClassyRounded({x, y, size, getNeighbor: bottomNeighbor}) {
|
|
745
|
+
let leftNeighbor = bottomNeighbor ? +bottomNeighbor(-1, 0) : 0, rightNeighbor = bottomNeighbor ? +bottomNeighbor(1, 0) : 0, topNeighbor = bottomNeighbor ? +bottomNeighbor(0, -1) : 0;
|
|
746
|
+
0 === leftNeighbor + rightNeighbor + topNeighbor + (bottomNeighbor = bottomNeighbor ? +bottomNeighbor(0, 1) : 0) ? this.basicCornersRounded({
|
|
747
|
+
x,
|
|
748
|
+
y,
|
|
749
|
+
size,
|
|
781
750
|
rotation: Math.PI / 2
|
|
782
|
-
}) :
|
|
783
|
-
x
|
|
784
|
-
y
|
|
785
|
-
size
|
|
751
|
+
}) : leftNeighbor || topNeighbor ? rightNeighbor || bottomNeighbor ? this.basicSquare({
|
|
752
|
+
x,
|
|
753
|
+
y,
|
|
754
|
+
size,
|
|
786
755
|
rotation: 0
|
|
787
756
|
}) : this.basicCornerExtraRounded({
|
|
788
|
-
x
|
|
789
|
-
y
|
|
790
|
-
size
|
|
757
|
+
x,
|
|
758
|
+
y,
|
|
759
|
+
size,
|
|
791
760
|
rotation: Math.PI / 2
|
|
792
761
|
}) : this.basicCornerExtraRounded({
|
|
793
|
-
x
|
|
794
|
-
y
|
|
795
|
-
size
|
|
762
|
+
x,
|
|
763
|
+
y,
|
|
764
|
+
size,
|
|
796
765
|
rotation: -Math.PI / 2
|
|
797
766
|
});
|
|
798
767
|
}
|
|
799
768
|
}
|
|
800
769
|
|
|
801
|
-
let
|
|
802
|
-
toDataURL:
|
|
803
|
-
if ("string" == typeof
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
const
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
},
|
|
810
|
-
},
|
|
811
|
-
|
|
770
|
+
let browserImageTools = {
|
|
771
|
+
toDataURL: url => "string" == typeof url && url.startsWith("data:") ? Promise.resolve(url) : new Promise(((resolve, reject) => {
|
|
772
|
+
if ("string" == typeof url) {
|
|
773
|
+
const xhr = new XMLHttpRequest;
|
|
774
|
+
xhr.onload = function() {
|
|
775
|
+
const reader = new FileReader;
|
|
776
|
+
reader.onloadend = function() {
|
|
777
|
+
resolve(reader.result);
|
|
778
|
+
}, reader.readAsDataURL(xhr.response);
|
|
779
|
+
}, xhr.onerror = xhr.onabort = xhr.ontimeout = reject, xhr.open("GET", url, !0),
|
|
780
|
+
xhr.responseType = "blob", xhr.send();
|
|
812
781
|
} else {
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
},
|
|
782
|
+
const reader = new FileReader;
|
|
783
|
+
reader.onloadend = function() {
|
|
784
|
+
resolve(reader.result);
|
|
785
|
+
}, reader.readAsDataURL(url);
|
|
817
786
|
}
|
|
818
787
|
})),
|
|
819
|
-
getSize: (
|
|
820
|
-
const
|
|
821
|
-
"string" ===
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
height: $image$jscomp$3$$.height
|
|
788
|
+
getSize: (src, crossOrigin) => new Promise(((resolve, reject) => {
|
|
789
|
+
const image = new Image;
|
|
790
|
+
"string" === crossOrigin && (image.crossOrigin = crossOrigin), image.onload = () => {
|
|
791
|
+
resolve({
|
|
792
|
+
width: image.width,
|
|
793
|
+
height: image.height
|
|
826
794
|
});
|
|
827
|
-
},
|
|
795
|
+
}, image.onerror = image.onabort = reject, "string" == typeof src ? image.src = src : browserImageTools.toDataURL(src).then((url => image.src = url)).catch(reject);
|
|
828
796
|
}))
|
|
829
797
|
};
|
|
830
798
|
|
|
831
|
-
function
|
|
832
|
-
var
|
|
833
|
-
let
|
|
834
|
-
if ("#" === (
|
|
835
|
-
let
|
|
836
|
-
4 >=
|
|
837
|
-
4 ===
|
|
838
|
-
8 ===
|
|
839
|
-
|
|
799
|
+
function parseColor(base) {
|
|
800
|
+
var m_parts = [];
|
|
801
|
+
let alpha = 1;
|
|
802
|
+
if ("#" === (base = base.toLowerCase())[0]) {
|
|
803
|
+
let size = (base = base.slice(1)).length;
|
|
804
|
+
4 >= size ? (m_parts = [ parseInt(base[0] + base[0], 16), parseInt(base[1] + base[1], 16), parseInt(base[2] + base[2], 16) ],
|
|
805
|
+
4 === size && (alpha = parseInt(base[3] + base[3], 16) / 255)) : (m_parts = [ parseInt(base[0] + base[1], 16), parseInt(base[2] + base[3], 16), parseInt(base[4] + base[5], 16) ],
|
|
806
|
+
8 === size && (alpha = parseInt(base[6] + base[7], 16) / 255)), m_parts[0] || (m_parts[0] = 0),
|
|
807
|
+
m_parts[1] || (m_parts[1] = 0), m_parts[2] || (m_parts[2] = 0);
|
|
840
808
|
} else {
|
|
841
|
-
if (!(
|
|
842
|
-
value:
|
|
843
|
-
alpha
|
|
809
|
+
if (!(m_parts = /^((?:rgba?))\s*\(([^)]*)\)/.exec(base))) return {
|
|
810
|
+
value: base,
|
|
811
|
+
alpha
|
|
844
812
|
};
|
|
845
|
-
|
|
846
|
-
3 ===
|
|
813
|
+
alpha = 3 < (m_parts = (m_parts = m_parts[2].trim().split(/\s*[,/]\s*|\s+/)).map(((v, i) => "%" === v[v.length - 1] ? (v = parseFloat(v) / 100,
|
|
814
|
+
3 === i ? v : 255 * v) : "none" === v ? 0 : parseFloat(v)))).length ? m_parts.pop() : 1;
|
|
847
815
|
}
|
|
848
816
|
return {
|
|
849
|
-
value: "#" +
|
|
850
|
-
alpha: Math.max(0, Math.min(1,
|
|
817
|
+
value: "#" + m_parts.map((v => Math.max(0, Math.min(255, v)).toString(16).padStart(2, "0"))).join(""),
|
|
818
|
+
alpha: Math.max(0, Math.min(1, alpha))
|
|
851
819
|
};
|
|
852
820
|
}
|
|
853
821
|
|
|
854
|
-
let
|
|
822
|
+
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 ] ];
|
|
855
823
|
|
|
856
|
-
class
|
|
824
|
+
class QRSVG {
|
|
857
825
|
get element() {
|
|
858
826
|
return this._element;
|
|
859
827
|
}
|
|
860
|
-
constructor(
|
|
861
|
-
this.options =
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
this._element.setAttribute("
|
|
865
|
-
this._element.
|
|
866
|
-
this.defs = this.document.createElementNS("http://www.w3.org/2000/svg", "defs"),
|
|
867
|
-
this._element.appendChild(this.defs), this.imageTools = $options$jscomp$35$$.imageTools || $browserImageTools$$;
|
|
828
|
+
constructor(options) {
|
|
829
|
+
this.options = options, this.document = options.document, this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
830
|
+
let width = numToAttr(options.width), height = numToAttr(options.height);
|
|
831
|
+
this._element.setAttribute("width", width), this._element.setAttribute("height", height),
|
|
832
|
+
this._element.setAttribute("viewBox", `0 0 ${width} ${height}`), this.defs = this.document.createElementNS("http://www.w3.org/2000/svg", "defs"),
|
|
833
|
+
this._element.appendChild(this.defs), this.imageTools = options.imageTools || browserImageTools;
|
|
868
834
|
}
|
|
869
835
|
get width() {
|
|
870
836
|
return this.options.width;
|
|
@@ -872,365 +838,343 @@ class $QRSVG$$ {
|
|
|
872
838
|
get height() {
|
|
873
839
|
return this.options.height;
|
|
874
840
|
}
|
|
875
|
-
async drawQR(
|
|
876
|
-
let
|
|
877
|
-
var
|
|
878
|
-
let
|
|
841
|
+
async drawQR(qr_size) {
|
|
842
|
+
let count = qr_size.getModuleCount();
|
|
843
|
+
var alignment_maxWidth_typeNumber = parseInt(((count - 17) / 4).toFixed(0), 10);
|
|
844
|
+
let dotSize = this.options.dotsOptions.size, drawImageSize = {
|
|
879
845
|
hideXDots: 0,
|
|
880
846
|
hideYDots: 0,
|
|
881
847
|
width: 0,
|
|
882
848
|
height: 0
|
|
883
849
|
};
|
|
884
|
-
if (this.qr =
|
|
885
|
-
|
|
886
|
-
let {imageOptions
|
|
887
|
-
if (
|
|
888
|
-
var
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
let {width
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
850
|
+
if (this.qr = qr_size, this.options.image) {
|
|
851
|
+
qr_size = await this.imageTools.getSize(this.options.image, this.options.imageOptions.crossOrigin);
|
|
852
|
+
let {imageOptions, errorCorrectionPercent} = this.options;
|
|
853
|
+
if (imageOptions.mode == ImageMode.background) {
|
|
854
|
+
var coverLevel_margin = this.options.backgroundOptions && this.options.backgroundOptions.margin || 0;
|
|
855
|
+
alignment_maxWidth_typeNumber = (this.options.width - 2 * coverLevel_margin * dotSize) * imageOptions.imageSize,
|
|
856
|
+
coverLevel_margin = (this.options.height - 2 * coverLevel_margin * dotSize) * imageOptions.imageSize;
|
|
857
|
+
let {width, height} = qr_size;
|
|
858
|
+
height = height / width * alignment_maxWidth_typeNumber, width = alignment_maxWidth_typeNumber,
|
|
859
|
+
height > coverLevel_margin && (width = width / height * coverLevel_margin, height = coverLevel_margin),
|
|
860
|
+
drawImageSize = {
|
|
895
861
|
hideXDots: 0,
|
|
896
862
|
hideYDots: 0,
|
|
897
|
-
width
|
|
898
|
-
height
|
|
863
|
+
width,
|
|
864
|
+
height
|
|
899
865
|
};
|
|
900
|
-
} else
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
if (0 >= $originalHeight$$ || 0 >= $originalWidth$$ || 0 >= $JSCompiler_object_inline_x_16_hideMax_maxHiddenDots$$ || 0 >= $dotSize$jscomp$7$$ || 4 * $margin$$ ** 2 > $JSCompiler_object_inline_x_16_hideMax_maxHiddenDots$$) return {
|
|
866
|
+
} else coverLevel_margin = imageOptions.imageSize * errorCorrectionPercent, alignment_maxWidth_typeNumber = QRUtil.getPatternPosition(alignment_maxWidth_typeNumber),
|
|
867
|
+
drawImageSize = function({originalHeight, originalWidth, maxHiddenDots: JSCompiler_object_inline_x_16_hideMax_maxHiddenDots, maxHiddenAxisDots: JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper, dotSize, margin}) {
|
|
868
|
+
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 {
|
|
904
869
|
height: 0,
|
|
905
870
|
width: 0,
|
|
906
871
|
hideYDots: 0,
|
|
907
872
|
hideXDots: 0
|
|
908
873
|
};
|
|
909
|
-
|
|
910
|
-
var
|
|
911
|
-
|
|
874
|
+
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));
|
|
875
|
+
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;
|
|
876
|
+
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;
|
|
912
877
|
do {
|
|
913
|
-
let
|
|
914
|
-
0 ==
|
|
915
|
-
let
|
|
916
|
-
0 ==
|
|
917
|
-
} while (.001 < Math.abs(
|
|
918
|
-
return 0 == (
|
|
919
|
-
0 == (
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
(
|
|
924
|
-
|
|
878
|
+
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));
|
|
879
|
+
0 == dotsMax % 2 && dotsMax++;
|
|
880
|
+
let dotsMin = Math.max(1, Math.ceil(size * JSCompiler_object_inline_y_15_dimMin_hideMin / JSCompiler_object_inline_x_14_dimMax + 2 * margin));
|
|
881
|
+
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;
|
|
882
|
+
} while (.001 < Math.abs(lower_maxH_size - JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper));
|
|
883
|
+
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++,
|
|
884
|
+
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++,
|
|
885
|
+
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,
|
|
886
|
+
JSCompiler_object_inline_y_15_dimMin_hideMin = JSCompiler_object_inline_x_16_hideMax_maxHiddenDots),
|
|
887
|
+
JSCompiler_object_inline_x_16_hideMax_maxHiddenDots = JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = (JSCompiler_object_inline_x_14_dimMax - 2 * margin) * dotSize,
|
|
888
|
+
(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,
|
|
889
|
+
JSCompiler_object_inline_x_16_hideMax_maxHiddenDots = lower_maxH_size * originalWidth / originalHeight),
|
|
925
890
|
{
|
|
926
|
-
height: Math.round(
|
|
927
|
-
width: Math.round(
|
|
928
|
-
hideYDots:
|
|
929
|
-
hideXDots:
|
|
891
|
+
height: Math.round(JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper + 2 * margin * dotSize),
|
|
892
|
+
width: Math.round(JSCompiler_object_inline_x_16_hideMax_maxHiddenDots + 2 * margin * dotSize),
|
|
893
|
+
hideYDots: JSCompiler_object_inline_y_15_dimMin_hideMin,
|
|
894
|
+
hideXDots: JSCompiler_object_inline_x_14_dimMax
|
|
930
895
|
};
|
|
931
896
|
}({
|
|
932
|
-
originalWidth:
|
|
933
|
-
originalHeight:
|
|
934
|
-
maxHiddenDots: Math.floor(
|
|
935
|
-
maxHiddenAxisDots:
|
|
936
|
-
dotSize
|
|
937
|
-
margin:
|
|
897
|
+
originalWidth: qr_size.width,
|
|
898
|
+
originalHeight: qr_size.height,
|
|
899
|
+
maxHiddenDots: Math.floor(coverLevel_margin * (count * count - 192 - 2 * (count - 16) - 25 * alignment_maxWidth_typeNumber.length ** 2)),
|
|
900
|
+
maxHiddenAxisDots: count - 14,
|
|
901
|
+
dotSize,
|
|
902
|
+
margin: imageOptions.margin
|
|
938
903
|
});
|
|
939
904
|
}
|
|
940
|
-
this.drawBackground(), this.options.imageOptions.mode !=
|
|
941
|
-
width:
|
|
942
|
-
height:
|
|
943
|
-
count
|
|
944
|
-
dotSize
|
|
945
|
-
}), this.drawDots(((
|
|
946
|
-
this.options.imageOptions.mode ==
|
|
947
|
-
width:
|
|
948
|
-
height:
|
|
949
|
-
count
|
|
950
|
-
dotSize
|
|
905
|
+
this.drawBackground(), this.options.imageOptions.mode != ImageMode.overlay && this.options.image && 0 < drawImageSize.width && 0 < drawImageSize.height && await this.drawImage({
|
|
906
|
+
width: drawImageSize.width,
|
|
907
|
+
height: drawImageSize.height,
|
|
908
|
+
count,
|
|
909
|
+
dotSize
|
|
910
|
+
}), 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))),
|
|
911
|
+
this.options.imageOptions.mode == ImageMode.overlay && this.options.image && 0 < drawImageSize.width && 0 < drawImageSize.height && await this.drawImage({
|
|
912
|
+
width: drawImageSize.width,
|
|
913
|
+
height: drawImageSize.height,
|
|
914
|
+
count,
|
|
915
|
+
dotSize
|
|
951
916
|
}), this.drawCorners();
|
|
952
917
|
}
|
|
953
918
|
drawBackground() {
|
|
954
|
-
let
|
|
955
|
-
if (this._element &&
|
|
919
|
+
let options = this.options;
|
|
920
|
+
if (this._element && options.backgroundOptions) {
|
|
956
921
|
this.createColor({
|
|
957
|
-
options:
|
|
958
|
-
color:
|
|
922
|
+
options: options.backgroundOptions.gradient,
|
|
923
|
+
color: options.backgroundOptions.color,
|
|
959
924
|
additionalRotation: 0,
|
|
960
925
|
x: 0,
|
|
961
926
|
y: 0,
|
|
962
|
-
height:
|
|
963
|
-
width:
|
|
927
|
+
height: options.height,
|
|
928
|
+
width: options.width,
|
|
964
929
|
name: "background-color"
|
|
965
930
|
});
|
|
966
|
-
let
|
|
931
|
+
let size = Math.min(options.width, options.height), element = this.document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
967
932
|
[this.backgroundMask, this.backgroundMaskGroup] = this.createMask("mask-background-color"),
|
|
968
|
-
this.defs.appendChild(this.backgroundMask),
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
this.backgroundMaskGroup.appendChild($element$jscomp$9$$);
|
|
933
|
+
this.defs.appendChild(this.backgroundMask), element.setAttribute("x", numToAttr((options.width - size) / 2)),
|
|
934
|
+
element.setAttribute("y", numToAttr((options.height - size) / 2)), element.setAttribute("width", numToAttr(size)),
|
|
935
|
+
element.setAttribute("height", numToAttr(size)), element.setAttribute("rx", numToAttr(size / 2 * (options.backgroundOptions.round || 0))),
|
|
936
|
+
this.backgroundMaskGroup.appendChild(element);
|
|
973
937
|
}
|
|
974
938
|
}
|
|
975
|
-
drawDots(
|
|
939
|
+
drawDots(alignment) {
|
|
976
940
|
if (!this.qr) throw "QR code is not defined";
|
|
977
|
-
let
|
|
978
|
-
var
|
|
979
|
-
if (
|
|
980
|
-
let
|
|
981
|
-
var
|
|
982
|
-
|
|
983
|
-
var
|
|
984
|
-
let
|
|
941
|
+
let options = this.options;
|
|
942
|
+
var count = this.qr.getModuleCount();
|
|
943
|
+
if (count > options.width || count > options.height) throw "The canvas is too small.";
|
|
944
|
+
let dotSize = this.options.dotsOptions.size;
|
|
945
|
+
var minSize_xFakeBeginning = Math.min(options.width, options.height);
|
|
946
|
+
options.imageOptions.mode == ImageMode.background && (minSize_xFakeBeginning -= 2 * dotSize * (options.imageOptions.margin || 0));
|
|
947
|
+
var colorCount_xBeginning = Math.floor((options.width - count * dotSize) / 2), yBeginning_yFakeBeginning = Math.floor((options.height - count * dotSize) / 2);
|
|
948
|
+
let dot = new QRDot(options.dotsOptions.type, this.document), overlayDot = new QRDot(DotType.tinySquare, this.document), markerDot = new QRDot(DotType.square, this.document);
|
|
985
949
|
[this.dotsMask, this.dotsMaskGroup] = this.createMask("mask-dot-color"), this.defs.appendChild(this.dotsMask),
|
|
986
|
-
|
|
950
|
+
options.imageOptions.mode == ImageMode.background && ([this.lightDotsMask, this.lightDotsMaskGroup] = this.createMask("mask-light-dot-color"),
|
|
987
951
|
this.defs.appendChild(this.lightDotsMask));
|
|
988
|
-
var
|
|
989
|
-
let
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
} else $fakeMatrix$$[$i$jscomp$7$$][$j$jscomp$1$$] = $options$jscomp$37$$.shape === $ShapeType$$.circle && Math.sqrt(($i$jscomp$7$$ - $center_jAlign$$) * ($i$jscomp$7$$ - $center_jAlign$$) + ($j$jscomp$1$$ - $center_jAlign$$) * ($j$jscomp$1$$ - $center_jAlign$$)) > $center_jAlign$$ ? void 0 : $i$jscomp$7$$ == $additionalDots$$ - 1 || $i$jscomp$7$$ == $fakeCount_margin$jscomp$2$$ - $additionalDots$$ || $j$jscomp$1$$ == $additionalDots$$ - 1 || $j$jscomp$1$$ == $fakeCount_margin$jscomp$2$$ - $additionalDots$$ ? ($j$jscomp$1$$ == $additionalDots$$ - 1 && ($i$jscomp$7$$ < $additionalDots$$ + 8 || $i$jscomp$7$$ > $fakeCount_margin$jscomp$2$$ - $additionalDots$$ - 9) || $j$jscomp$1$$ == $fakeCount_margin$jscomp$2$$ - $additionalDots$$ && $i$jscomp$7$$ < $additionalDots$$ + 8 || $i$jscomp$7$$ == $additionalDots$$ - 1 && ($j$jscomp$1$$ < $additionalDots$$ + 8 || $j$jscomp$1$$ > $fakeCount_margin$jscomp$2$$ - $additionalDots$$ - 9) || $i$jscomp$7$$ == $fakeCount_margin$jscomp$2$$ - $additionalDots$$ && $j$jscomp$1$$ < $additionalDots$$ + 8) && void 0 : this.qr.isDark(0 > $j$jscomp$1$$ - 2 * $additionalDots$$ ? $j$jscomp$1$$ : $j$jscomp$1$$ >= $count$jscomp$40_iAlign$$ ? $j$jscomp$1$$ - 2 * $additionalDots$$ : $j$jscomp$1$$ - $additionalDots$$, 0 > $i$jscomp$7$$ - 2 * $additionalDots$$ ? $i$jscomp$7$$ : $i$jscomp$7$$ >= $count$jscomp$40_iAlign$$ ? $i$jscomp$7$$ - 2 * $additionalDots$$ : $i$jscomp$7$$ - $additionalDots$$);
|
|
952
|
+
var fakeCount_margin = 0;
|
|
953
|
+
let additionalDots = 0;
|
|
954
|
+
fakeCount_margin = count, options.shape === ShapeType.circle ? (fakeCount_margin = this.options.backgroundOptions && this.options.backgroundOptions.margin || 0,
|
|
955
|
+
additionalDots = Math.floor((minSize_xFakeBeginning / dotSize - count - 2 * fakeCount_margin) / 2),
|
|
956
|
+
fakeCount_margin = count + 2 * additionalDots) : options.imageOptions.mode == ImageMode.background && (additionalDots = 1,
|
|
957
|
+
fakeCount_margin = count + 2 * additionalDots), minSize_xFakeBeginning = colorCount_xBeginning - additionalDots * dotSize,
|
|
958
|
+
yBeginning_yFakeBeginning -= additionalDots * dotSize, colorCount_xBeginning = count + 2 * additionalDots;
|
|
959
|
+
let fakeMatrix = Array(fakeCount_margin);
|
|
960
|
+
var center_jAlign = Math.floor(fakeCount_margin / 2);
|
|
961
|
+
for (let i = 0; i < fakeCount_margin; i++) {
|
|
962
|
+
fakeMatrix[i] = Array(fakeCount_margin);
|
|
963
|
+
for (let j = 0; j < fakeCount_margin; j++) if (i > additionalDots - 1 && i < fakeCount_margin - additionalDots && j > additionalDots - 1 && j < fakeCount_margin - additionalDots) {
|
|
964
|
+
let ii = i - additionalDots, jj = j - additionalDots;
|
|
965
|
+
alignment && !alignment(ii, jj) ? fakeMatrix[i][j] = void 0 : fakeMatrix[i][j] = !!this.qr.isDark(jj, ii);
|
|
966
|
+
} else fakeMatrix[i][j] = options.shape === ShapeType.circle && Math.sqrt((i - center_jAlign) * (i - center_jAlign) + (j - center_jAlign) * (j - center_jAlign)) > center_jAlign ? void 0 : i == additionalDots - 1 || i == fakeCount_margin - additionalDots || j == additionalDots - 1 || j == fakeCount_margin - additionalDots ? (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.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);
|
|
1004
967
|
}
|
|
1005
|
-
|
|
1006
|
-
for (let
|
|
1007
|
-
|
|
1008
|
-
for (let
|
|
1009
|
-
null !=
|
|
1010
|
-
|
|
1011
|
-
x:
|
|
1012
|
-
y:
|
|
1013
|
-
size:
|
|
1014
|
-
getNeighbor: (
|
|
1015
|
-
}),
|
|
1016
|
-
x:
|
|
1017
|
-
y:
|
|
1018
|
-
size:
|
|
1019
|
-
getNeighbor: (
|
|
1020
|
-
}),
|
|
968
|
+
alignment = QRUtil.getPatternPosition((count - 17) / 4);
|
|
969
|
+
for (let i = 0; i < fakeCount_margin; i++) {
|
|
970
|
+
count = alignment.find((v => i - additionalDots > v - 3 && i - additionalDots < v + 3));
|
|
971
|
+
for (let j = 0; j < fakeCount_margin; j++) center_jAlign = alignment.find((v => j - additionalDots > v - 3 && j - additionalDots < v + 3)),
|
|
972
|
+
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),
|
|
973
|
+
fakeMatrix[i][j] ? (dot.draw({
|
|
974
|
+
x: minSize_xFakeBeginning + i * dotSize,
|
|
975
|
+
y: yBeginning_yFakeBeginning + j * dotSize,
|
|
976
|
+
size: dotSize,
|
|
977
|
+
getNeighbor: (xOffset, yOffset) => !0 === fakeMatrix[i + xOffset]?.[j + yOffset]
|
|
978
|
+
}), dot.element && this.dotsMaskGroup && this.dotsMaskGroup.appendChild(dot.element)) : this.lightDotsMask && (dot.draw({
|
|
979
|
+
x: minSize_xFakeBeginning + i * dotSize,
|
|
980
|
+
y: yBeginning_yFakeBeginning + j * dotSize,
|
|
981
|
+
size: dotSize,
|
|
982
|
+
getNeighbor: (xOffset, yOffset) => !1 === fakeMatrix[i + xOffset]?.[j + yOffset]
|
|
983
|
+
}), dot.element && this.lightDotsMaskGroup && this.lightDotsMaskGroup.appendChild(dot.element)));
|
|
1021
984
|
}
|
|
1022
985
|
this.lightDotsMask && this.createColor({
|
|
1023
|
-
options:
|
|
1024
|
-
color:
|
|
986
|
+
options: options.imageOptions.fill.gradient,
|
|
987
|
+
color: options.imageOptions.fill.color,
|
|
1025
988
|
additionalRotation: 0,
|
|
1026
|
-
x:
|
|
1027
|
-
y:
|
|
1028
|
-
height:
|
|
1029
|
-
width:
|
|
989
|
+
x: minSize_xFakeBeginning,
|
|
990
|
+
y: yBeginning_yFakeBeginning,
|
|
991
|
+
height: colorCount_xBeginning * dotSize,
|
|
992
|
+
width: colorCount_xBeginning * dotSize,
|
|
1030
993
|
name: "light-dot-color"
|
|
1031
994
|
}), this.createColor({
|
|
1032
|
-
options:
|
|
1033
|
-
color:
|
|
995
|
+
options: options.dotsOptions?.gradient,
|
|
996
|
+
color: options.dotsOptions.color,
|
|
1034
997
|
additionalRotation: 0,
|
|
1035
|
-
x:
|
|
1036
|
-
y:
|
|
1037
|
-
height:
|
|
1038
|
-
width:
|
|
998
|
+
x: minSize_xFakeBeginning,
|
|
999
|
+
y: yBeginning_yFakeBeginning,
|
|
1000
|
+
height: colorCount_xBeginning * dotSize,
|
|
1001
|
+
width: colorCount_xBeginning * dotSize,
|
|
1039
1002
|
name: "dot-color"
|
|
1040
1003
|
});
|
|
1041
1004
|
}
|
|
1042
1005
|
drawCorners() {
|
|
1043
1006
|
if (!this.qr) throw "QR code is not defined";
|
|
1044
|
-
let
|
|
1007
|
+
let options = this.options;
|
|
1045
1008
|
if (!this._element) throw "Element code is not defined";
|
|
1046
|
-
let
|
|
1047
|
-
[ [ 0, 0, 0 ], [ 1, 0, Math.PI / 2 ], [ 0, 1, -Math.PI / 2 ] ].forEach((([
|
|
1048
|
-
let
|
|
1049
|
-
var
|
|
1050
|
-
let
|
|
1051
|
-
var
|
|
1052
|
-
if (
|
|
1053
|
-
this.defs.appendChild(
|
|
1054
|
-
|
|
1055
|
-
options:
|
|
1056
|
-
color:
|
|
1057
|
-
additionalRotation:
|
|
1058
|
-
x
|
|
1059
|
-
y
|
|
1060
|
-
height:
|
|
1061
|
-
width:
|
|
1062
|
-
name: `corners-square-color-${
|
|
1063
|
-
})),
|
|
1064
|
-
x
|
|
1065
|
-
y
|
|
1066
|
-
size:
|
|
1067
|
-
rotation:
|
|
1068
|
-
}),
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
for (let
|
|
1072
|
-
x:
|
|
1073
|
-
y:
|
|
1074
|
-
size:
|
|
1075
|
-
getNeighbor: (
|
|
1076
|
-
}),
|
|
1077
|
-
x:
|
|
1078
|
-
y:
|
|
1079
|
-
size:
|
|
1080
|
-
getNeighbor: (
|
|
1081
|
-
}),
|
|
1082
|
-
if (this.lightDotsMask) for (let
|
|
1083
|
-
x:
|
|
1084
|
-
y:
|
|
1085
|
-
size:
|
|
1086
|
-
getNeighbor: (
|
|
1087
|
-
|
|
1088
|
-
}), $cornersDotMask_cornersSquare_dot$jscomp$1$$.element && this.lightDotsMaskGroup && this.lightDotsMaskGroup.appendChild($cornersDotMask_cornersSquare_dot$jscomp$1$$.element));
|
|
1009
|
+
let count = this.qr.getModuleCount(), dotSize = this.options.dotsOptions.size, cornersSquareSize = 7 * dotSize, cornersDotSize = 3 * dotSize, xBeginning = Math.floor((options.width - count * dotSize) / 2), yBeginning = Math.floor((options.height - count * dotSize) / 2);
|
|
1010
|
+
[ [ 0, 0, 0 ], [ 1, 0, Math.PI / 2 ], [ 0, 1, -Math.PI / 2 ] ].forEach((([column_cornersDot, row, dot]) => {
|
|
1011
|
+
let x = xBeginning + column_cornersDot * dotSize * (count - 7), y = yBeginning + row * dotSize * (count - 7);
|
|
1012
|
+
var cornersDotMaskGroup_cornersSquareMask = this.dotsMask;
|
|
1013
|
+
let cornersSquareMaskGroup = this.dotsMaskGroup;
|
|
1014
|
+
var cornersDotMask_cornersSquare_dot = this.dotsMask;
|
|
1015
|
+
if (cornersDotMaskGroup_cornersSquareMask = this.dotsMaskGroup, (options.cornersSquareOptions?.gradient || options.cornersSquareOptions?.color) && ([cornersDotMaskGroup_cornersSquareMask, cornersSquareMaskGroup] = this.createMask(`mask-corners-square-color-${column_cornersDot}-${row}`),
|
|
1016
|
+
this.defs.appendChild(cornersDotMaskGroup_cornersSquareMask), cornersDotMask_cornersSquare_dot = cornersDotMaskGroup_cornersSquareMask,
|
|
1017
|
+
cornersDotMaskGroup_cornersSquareMask = cornersSquareMaskGroup, this.createColor({
|
|
1018
|
+
options: options.cornersSquareOptions?.gradient,
|
|
1019
|
+
color: options.cornersSquareOptions?.color,
|
|
1020
|
+
additionalRotation: dot,
|
|
1021
|
+
x,
|
|
1022
|
+
y,
|
|
1023
|
+
height: cornersSquareSize,
|
|
1024
|
+
width: cornersSquareSize,
|
|
1025
|
+
name: `corners-square-color-${column_cornersDot}-${row}`
|
|
1026
|
+
})), options.cornersSquareOptions?.type) (cornersDotMask_cornersSquare_dot = new QRCornerSquare(options.cornersSquareOptions.type, this.document)).draw({
|
|
1027
|
+
x,
|
|
1028
|
+
y,
|
|
1029
|
+
size: cornersSquareSize,
|
|
1030
|
+
rotation: dot
|
|
1031
|
+
}), cornersDotMask_cornersSquare_dot.element && cornersSquareMaskGroup && cornersSquareMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.element),
|
|
1032
|
+
cornersDotMask_cornersSquare_dot.fill && this.lightDotsMaskGroup && this.lightDotsMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.fill); else {
|
|
1033
|
+
cornersDotMask_cornersSquare_dot = new QRDot(options.dotsOptions.type, this.document);
|
|
1034
|
+
for (let i = 0; i < squareMask.length; i++) for (let j = 0; j < squareMask[i].length; j++) squareMask[i]?.[j] ? (cornersDotMask_cornersSquare_dot.draw({
|
|
1035
|
+
x: x + i * dotSize,
|
|
1036
|
+
y: y + j * dotSize,
|
|
1037
|
+
size: dotSize,
|
|
1038
|
+
getNeighbor: (xOffset, yOffset) => !!squareMask[i + xOffset]?.[j + yOffset]
|
|
1039
|
+
}), cornersDotMask_cornersSquare_dot.element && cornersSquareMaskGroup && cornersSquareMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.element)) : this.lightDotsMask && !dotMask[i]?.[j] && (cornersDotMask_cornersSquare_dot.draw({
|
|
1040
|
+
x: x + i * dotSize,
|
|
1041
|
+
y: y + j * dotSize,
|
|
1042
|
+
size: dotSize,
|
|
1043
|
+
getNeighbor: (xOffset, yOffset) => !squareMask[i + xOffset]?.[j + yOffset] && !dotMask[i + xOffset]?.[j + yOffset]
|
|
1044
|
+
}), cornersDotMask_cornersSquare_dot.element && this.lightDotsMaskGroup && this.lightDotsMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.element));
|
|
1045
|
+
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({
|
|
1046
|
+
x: x + i * dotSize,
|
|
1047
|
+
y: y + j * dotSize,
|
|
1048
|
+
size: dotSize,
|
|
1049
|
+
getNeighbor: (ii, jj) => (jj = j + jj, -1 <= (ii = i + ii) && 7 >= ii && -1 <= jj && 7 >= jj && (-1 == ii || 7 == ii || -1 == jj || 7 == jj))
|
|
1050
|
+
}), cornersDotMask_cornersSquare_dot.element && this.lightDotsMaskGroup && this.lightDotsMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.element));
|
|
1089
1051
|
}
|
|
1090
|
-
if ((
|
|
1091
|
-
this.defs.appendChild(
|
|
1092
|
-
options:
|
|
1093
|
-
color:
|
|
1094
|
-
additionalRotation:
|
|
1095
|
-
x:
|
|
1096
|
-
y:
|
|
1097
|
-
height:
|
|
1098
|
-
width:
|
|
1099
|
-
name: `corners-dot-color-${
|
|
1100
|
-
})),
|
|
1101
|
-
x:
|
|
1102
|
-
y:
|
|
1103
|
-
size:
|
|
1104
|
-
rotation:
|
|
1105
|
-
}),
|
|
1106
|
-
|
|
1107
|
-
for (let
|
|
1108
|
-
x:
|
|
1109
|
-
y:
|
|
1110
|
-
size:
|
|
1111
|
-
getNeighbor: (
|
|
1112
|
-
}),
|
|
1052
|
+
if ((options.cornersDotOptions?.gradient || options.cornersDotOptions?.color) && ([cornersDotMask_cornersSquare_dot, cornersDotMaskGroup_cornersSquareMask] = this.createMask(`mask-corners-dot-color-${column_cornersDot}-${row}`),
|
|
1053
|
+
this.defs.appendChild(cornersDotMask_cornersSquare_dot), this.createColor({
|
|
1054
|
+
options: options.cornersDotOptions?.gradient,
|
|
1055
|
+
color: options.cornersDotOptions?.color,
|
|
1056
|
+
additionalRotation: dot,
|
|
1057
|
+
x: x + 2 * dotSize,
|
|
1058
|
+
y: y + 2 * dotSize,
|
|
1059
|
+
height: cornersDotSize,
|
|
1060
|
+
width: cornersDotSize,
|
|
1061
|
+
name: `corners-dot-color-${column_cornersDot}-${row}`
|
|
1062
|
+
})), options.cornersDotOptions?.type) (column_cornersDot = new QRCornerDot(options.cornersDotOptions.type, this.document)).draw({
|
|
1063
|
+
x: x + 2 * dotSize,
|
|
1064
|
+
y: y + 2 * dotSize,
|
|
1065
|
+
size: cornersDotSize,
|
|
1066
|
+
rotation: dot
|
|
1067
|
+
}), column_cornersDot.element && cornersDotMaskGroup_cornersSquareMask && cornersDotMaskGroup_cornersSquareMask.appendChild(column_cornersDot.element); else {
|
|
1068
|
+
dot = new QRDot(options.dotsOptions.type, this.document);
|
|
1069
|
+
for (let i = 0; i < dotMask.length; i++) for (let j = 0; j < dotMask[i].length; j++) dotMask[i]?.[j] && (dot.draw({
|
|
1070
|
+
x: x + i * dotSize,
|
|
1071
|
+
y: y + j * dotSize,
|
|
1072
|
+
size: dotSize,
|
|
1073
|
+
getNeighbor: (xOffset, yOffset) => !!dotMask[i + xOffset]?.[j + yOffset]
|
|
1074
|
+
}), dot.element && cornersDotMaskGroup_cornersSquareMask && cornersDotMaskGroup_cornersSquareMask.appendChild(dot.element));
|
|
1113
1075
|
}
|
|
1114
1076
|
}));
|
|
1115
1077
|
}
|
|
1116
|
-
async drawImage({width:
|
|
1117
|
-
var
|
|
1118
|
-
if (
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
$encoding$jscomp$3_yBeginning$jscomp$2$$ = $container_data$jscomp$80_imageUrl_margin$jscomp$3_rootEl$$.substring(0, $dotSize$jscomp$11_i$jscomp$12$$),
|
|
1128
|
-
$container_data$jscomp$80_imageUrl_margin$jscomp$3_rootEl$$ = $container_data$jscomp$80_imageUrl_margin$jscomp$3_rootEl$$.substring($dotSize$jscomp$11_i$jscomp$12$$ + 1),
|
|
1129
|
-
"base64" === $encoding$jscomp$3_yBeginning$jscomp$2$$) $container_data$jscomp$80_imageUrl_margin$jscomp$3_rootEl$$ = "function" == typeof atob ? atob($container_data$jscomp$80_imageUrl_margin$jscomp$3_rootEl$$) : Buffer.from($container_data$jscomp$80_imageUrl_margin$jscomp$3_rootEl$$, "base64").toString("utf8"); else $container_data$jscomp$80_imageUrl_margin$jscomp$3_rootEl$$ = "";
|
|
1130
|
-
$container_data$jscomp$80_imageUrl_margin$jscomp$3_rootEl$$ && ($container_data$jscomp$80_imageUrl_margin$jscomp$3_rootEl$$ = (new DOMParser).parseFromString($container_data$jscomp$80_imageUrl_margin$jscomp$3_rootEl$$, "text/xml"),
|
|
1131
|
-
($container_data$jscomp$80_imageUrl_margin$jscomp$3_rootEl$$ = Array.from($container_data$jscomp$80_imageUrl_margin$jscomp$3_rootEl$$.getElementsByTagName("svg"))).length && ($image$jscomp$4_options$jscomp$39$$ = $container_data$jscomp$80_imageUrl_margin$jscomp$3_rootEl$$[0]).setAttribute("overflow", "visible"));
|
|
1078
|
+
async drawImage({width: dw_width, height: dh_height, count, dotSize}) {
|
|
1079
|
+
var image = this.options, dx = Math.floor((image.width - count * dotSize) / 2), encoding = Math.floor((image.height - count * dotSize) / 2), container_data = image.imageOptions.margin * dotSize;
|
|
1080
|
+
if (image.imageOptions.mode == ImageMode.background && (container_data = 0), dx = dx + container_data + (count * dotSize - dw_width) / 2,
|
|
1081
|
+
count = encoding + container_data + (count * dotSize - dh_height) / 2, dw_width -= 2 * container_data,
|
|
1082
|
+
dh_height -= 2 * container_data, container_data = await this.imageTools.toDataURL(image.image || ""),
|
|
1083
|
+
(image = this.document.createElementNS("http://www.w3.org/2000/svg", "image")).setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", container_data || ""),
|
|
1084
|
+
container_data.startsWith("data:image/svg+xml;")) {
|
|
1085
|
+
if (dotSize = (container_data = container_data.substring(19)).indexOf(","), encoding = container_data.substring(0, dotSize),
|
|
1086
|
+
container_data = container_data.substring(dotSize + 1), "base64" === encoding) container_data = "function" == typeof atob ? atob(container_data) : Buffer.from(container_data, "base64").toString("utf8"); else container_data = "";
|
|
1087
|
+
container_data && (container_data = (new DOMParser).parseFromString(container_data, "text/xml"),
|
|
1088
|
+
(container_data = Array.from(container_data.getElementsByTagName("svg"))).length && (image = container_data[0]).setAttribute("overflow", "visible"));
|
|
1132
1089
|
}
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
$y$jscomp$119_y1$jscomp$5$$ += $height$jscomp$28$$ / 2, $x$jscomp$135_x1$jscomp$5$$ += $width$jscomp$31$$ / 2 / Math.tan($color$jscomp$3_rotation$jscomp$28$$)) : $additionalRotation_positiveRotation$$ > .75 * Math.PI && $additionalRotation_positiveRotation$$ <= 1.25 * Math.PI ? ($size$jscomp$71_x0$jscomp$2$$ += $width$jscomp$31$$ / 2,
|
|
1161
|
-
$y0$jscomp$2$$ += $height$jscomp$28$$ / 2 * Math.tan($color$jscomp$3_rotation$jscomp$28$$),
|
|
1162
|
-
$x$jscomp$135_x1$jscomp$5$$ -= $width$jscomp$31$$ / 2, $y$jscomp$119_y1$jscomp$5$$ -= $height$jscomp$28$$ / 2 * Math.tan($color$jscomp$3_rotation$jscomp$28$$)) : $additionalRotation_positiveRotation$$ > 1.25 * Math.PI && $additionalRotation_positiveRotation$$ <= 1.75 * Math.PI && ($y0$jscomp$2$$ += $height$jscomp$28$$ / 2,
|
|
1163
|
-
$size$jscomp$71_x0$jscomp$2$$ += $width$jscomp$31$$ / 2 / Math.tan($color$jscomp$3_rotation$jscomp$28$$),
|
|
1164
|
-
$y$jscomp$119_y1$jscomp$5$$ -= $height$jscomp$28$$ / 2, $x$jscomp$135_x1$jscomp$5$$ -= $width$jscomp$31$$ / 2 / Math.tan($color$jscomp$3_rotation$jscomp$28$$)),
|
|
1165
|
-
$gradient$jscomp$1$$ = this.document.createElementNS("http://www.w3.org/2000/svg", "linearGradient"),
|
|
1166
|
-
$gradient$jscomp$1$$.setAttribute("id", $name$jscomp$73$$), $gradient$jscomp$1$$.setAttribute("gradientUnits", "userSpaceOnUse"),
|
|
1167
|
-
$gradient$jscomp$1$$.setAttribute("x1", $numToAttr$$($size$jscomp$71_x0$jscomp$2$$)),
|
|
1168
|
-
$gradient$jscomp$1$$.setAttribute("y1", $numToAttr$$($y0$jscomp$2$$)), $gradient$jscomp$1$$.setAttribute("x2", $numToAttr$$($x$jscomp$135_x1$jscomp$5$$)),
|
|
1169
|
-
$gradient$jscomp$1$$.setAttribute("y2", $numToAttr$$($y$jscomp$119_y1$jscomp$5$$));
|
|
1090
|
+
image.setAttribute("x", numToAttr(dx)), image.setAttribute("y", numToAttr(count)),
|
|
1091
|
+
image.setAttribute("width", `${numToAttr(dw_width)}px`), image.setAttribute("height", `${numToAttr(dh_height)}px`),
|
|
1092
|
+
this._element.appendChild(image);
|
|
1093
|
+
}
|
|
1094
|
+
createColor({options, color, additionalRotation: additionalRotation_positiveRotation, x, y, height, width, name}) {
|
|
1095
|
+
var size = width > height ? width : height;
|
|
1096
|
+
let rect = this.document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
1097
|
+
if (rect.setAttribute("x", numToAttr(x)), rect.setAttribute("y", numToAttr(y)),
|
|
1098
|
+
rect.setAttribute("height", numToAttr(height)), rect.setAttribute("width", numToAttr(width)),
|
|
1099
|
+
rect.setAttribute("style", `mask:url(#mask-${name})`), options) {
|
|
1100
|
+
let gradient;
|
|
1101
|
+
if (options.type === GradientType.radial) gradient = this.document.createElementNS("http://www.w3.org/2000/svg", "radialGradient"),
|
|
1102
|
+
gradient.setAttribute("id", name), gradient.setAttribute("gradientUnits", "userSpaceOnUse"),
|
|
1103
|
+
gradient.setAttribute("fx", numToAttr(x + width / 2)), gradient.setAttribute("fy", numToAttr(y + height / 2)),
|
|
1104
|
+
gradient.setAttribute("cx", numToAttr(x + width / 2)), gradient.setAttribute("cy", numToAttr(y + height / 2)),
|
|
1105
|
+
gradient.setAttribute("r", numToAttr(size / 2)); else {
|
|
1106
|
+
size = x + width / 2;
|
|
1107
|
+
let y0 = y + height / 2;
|
|
1108
|
+
x += width / 2, y += height / 2, 0 <= (additionalRotation_positiveRotation = ((color = ((options.rotation || 0) + additionalRotation_positiveRotation) % (2 * Math.PI)) + 2 * Math.PI) % (2 * Math.PI)) && additionalRotation_positiveRotation <= .25 * Math.PI || additionalRotation_positiveRotation > 1.75 * Math.PI && additionalRotation_positiveRotation <= 2 * Math.PI ? (size -= width / 2,
|
|
1109
|
+
y0 -= height / 2 * Math.tan(color), x += width / 2, y += height / 2 * Math.tan(color)) : additionalRotation_positiveRotation > .25 * Math.PI && additionalRotation_positiveRotation <= .75 * Math.PI ? (y0 -= height / 2,
|
|
1110
|
+
size -= width / 2 / Math.tan(color), y += height / 2, x += width / 2 / Math.tan(color)) : additionalRotation_positiveRotation > .75 * Math.PI && additionalRotation_positiveRotation <= 1.25 * Math.PI ? (size += width / 2,
|
|
1111
|
+
y0 += height / 2 * Math.tan(color), x -= width / 2, y -= height / 2 * Math.tan(color)) : additionalRotation_positiveRotation > 1.25 * Math.PI && additionalRotation_positiveRotation <= 1.75 * Math.PI && (y0 += height / 2,
|
|
1112
|
+
size += width / 2 / Math.tan(color), y -= height / 2, x -= width / 2 / Math.tan(color)),
|
|
1113
|
+
gradient = this.document.createElementNS("http://www.w3.org/2000/svg", "linearGradient"),
|
|
1114
|
+
gradient.setAttribute("id", name), gradient.setAttribute("gradientUnits", "userSpaceOnUse"),
|
|
1115
|
+
gradient.setAttribute("x1", numToAttr(size)), gradient.setAttribute("y1", numToAttr(y0)),
|
|
1116
|
+
gradient.setAttribute("x2", numToAttr(x)), gradient.setAttribute("y2", numToAttr(y));
|
|
1170
1117
|
}
|
|
1171
|
-
|
|
1172
|
-
let
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
$mask$jscomp$7$$.setAttribute("height", $numToAttr$$($options$jscomp$41$$.height)),
|
|
1188
|
-
($group_id$jscomp$5$$ = this.document.createElementNS("http://www.w3.org/2000/svg", "g")).setAttribute("fill", "#fff"),
|
|
1189
|
-
$mask$jscomp$7$$.appendChild($group_id$jscomp$5$$), [ $mask$jscomp$7$$, $group_id$jscomp$5$$ ];
|
|
1118
|
+
options.colorStops.forEach((({offset, color}) => {
|
|
1119
|
+
let stop = this.document.createElementNS("http://www.w3.org/2000/svg", "stop");
|
|
1120
|
+
stop.setAttribute("offset", `${numToAttr(100 * offset)}%`), offset = parseColor(color),
|
|
1121
|
+
stop.setAttribute("stop-color", offset.value), 1 > offset.alpha && stop.setAttribute("stop-opacity", offset.alpha.toFixed(7)),
|
|
1122
|
+
gradient.appendChild(stop);
|
|
1123
|
+
})), rect.setAttribute("fill", `url(#${name})`), this.defs.appendChild(gradient);
|
|
1124
|
+
} else color && (options = parseColor(color), rect.setAttribute("fill", options.value),
|
|
1125
|
+
1 > options.alpha && rect.setAttribute("opacity", options.alpha.toFixed(7)));
|
|
1126
|
+
this._element.appendChild(rect);
|
|
1127
|
+
}
|
|
1128
|
+
createMask(group_id) {
|
|
1129
|
+
let options = this.options, mask = this.document.createElementNS("http://www.w3.org/2000/svg", "mask");
|
|
1130
|
+
return mask.setAttribute("id", group_id), mask.setAttribute("maskUnits", "userSpaceOnUse"),
|
|
1131
|
+
mask.setAttribute("x", "0"), mask.setAttribute("y", "0"), mask.setAttribute("width", numToAttr(options.width)),
|
|
1132
|
+
mask.setAttribute("height", numToAttr(options.height)), (group_id = this.document.createElementNS("http://www.w3.org/2000/svg", "g")).setAttribute("fill", "#fff"),
|
|
1133
|
+
mask.appendChild(group_id), [ mask, group_id ];
|
|
1190
1134
|
}
|
|
1191
1135
|
}
|
|
1192
1136
|
|
|
1193
1137
|
Object.assign(QRCodeMinimal.stringToBytesFuncs, stringToBytes_UTF8);
|
|
1194
1138
|
|
|
1195
|
-
let
|
|
1139
|
+
let QRCodeStyling$1 = class {
|
|
1196
1140
|
get size() {
|
|
1197
1141
|
if (this.qrSVG) return {
|
|
1198
1142
|
width: this.qrSVG.width,
|
|
1199
1143
|
height: this.qrSVG.height
|
|
1200
1144
|
};
|
|
1201
1145
|
}
|
|
1202
|
-
constructor(
|
|
1203
|
-
this.options =
|
|
1146
|
+
constructor(options) {
|
|
1147
|
+
this.options = options ? sanitizeOptions(mergeDeep(defaultOptions, options)) : defaultOptions,
|
|
1204
1148
|
this.update();
|
|
1205
1149
|
}
|
|
1206
|
-
update(
|
|
1207
|
-
this.container && (this.container.innerHTML = ""), this.options =
|
|
1150
|
+
update(mode) {
|
|
1151
|
+
this.container && (this.container.innerHTML = ""), this.options = mode ? sanitizeOptions(mergeDeep(this.options, mode)) : this.options,
|
|
1208
1152
|
this.options.data && (this.options.stringToBytesFuncs && (Object.assign(QRCodeMinimal.stringToBytesFuncs, this.options.stringToBytesFuncs),
|
|
1209
1153
|
delete this.options.stringToBytesFuncs), this.qr = new QRCodeMinimal(this.options.qrOptions.typeNumber, this.options.qrOptions.errorCorrectionLevel),
|
|
1210
|
-
|
|
1154
|
+
mode = this.options.qrOptions.mode || function(data) {
|
|
1211
1155
|
switch (!0) {
|
|
1212
|
-
case /^[0-9]*$/.test(
|
|
1156
|
+
case /^[0-9]*$/.test(data):
|
|
1213
1157
|
return Mode.numeric;
|
|
1214
1158
|
|
|
1215
|
-
case /^[0-9A-Z $%*+\-./:]*$/.test(
|
|
1159
|
+
case /^[0-9A-Z $%*+\-./:]*$/.test(data):
|
|
1216
1160
|
return Mode.alphanumeric;
|
|
1217
1161
|
|
|
1218
|
-
case /[^\u0000-\u00ff]/.test(
|
|
1162
|
+
case /[^\u0000-\u00ff]/.test(data):
|
|
1219
1163
|
return Mode.unicode;
|
|
1220
1164
|
|
|
1221
1165
|
default:
|
|
1222
1166
|
return Mode.byte;
|
|
1223
1167
|
}
|
|
1224
|
-
}(this.options.data), this.qr.addData(this.options.data,
|
|
1225
|
-
this.
|
|
1168
|
+
}(this.options.data), this.qr.addData(this.options.data, mode), this.qr.make(),
|
|
1169
|
+
this.setupSvg(), this.append(this.container));
|
|
1226
1170
|
}
|
|
1227
|
-
append(
|
|
1228
|
-
|
|
1229
|
-
this.container =
|
|
1171
|
+
append(container) {
|
|
1172
|
+
container && (this.qrSVG?.element && container.appendChild(this.qrSVG.element),
|
|
1173
|
+
this.container = container);
|
|
1230
1174
|
}
|
|
1231
|
-
applyExtension(
|
|
1232
|
-
if (
|
|
1233
|
-
this.extension =
|
|
1175
|
+
applyExtension(extension) {
|
|
1176
|
+
if (!extension) throw "Extension function should be defined.";
|
|
1177
|
+
this.extension = extension, this.update();
|
|
1234
1178
|
}
|
|
1235
1179
|
deleteExtension() {
|
|
1236
1180
|
this.extension = void 0, this.update();
|
|
@@ -1242,17 +1186,16 @@ let $QRCodeStyling$1$$ = class {
|
|
|
1242
1186
|
}
|
|
1243
1187
|
setupSvg() {
|
|
1244
1188
|
if (this.qr) {
|
|
1245
|
-
var
|
|
1246
|
-
this.options.imageOptions.mode ==
|
|
1247
|
-
0 == (
|
|
1248
|
-
var
|
|
1249
|
-
this.options.imageOptions.mode ==
|
|
1250
|
-
|
|
1251
|
-
this.qrSVG = new $QRSVG$$({
|
|
1189
|
+
var count = this.qr.getModuleCount();
|
|
1190
|
+
this.options.imageOptions.mode == ImageMode.background && this.options.shape != ShapeType.circle && (count += 2),
|
|
1191
|
+
0 == (count = Math.ceil((this.options.shape == ShapeType.circle ? Math.sqrt(2) : 1) * count)) % 2 && --count;
|
|
1192
|
+
var margin = this.options.backgroundOptions && this.options.backgroundOptions.margin || 0;
|
|
1193
|
+
this.options.imageOptions.mode == ImageMode.background && (margin += this.options.imageOptions.margin || 0),
|
|
1194
|
+
count = Math.ceil(this.options.dotsOptions.size * (count + 2 * margin)), this.qrSVG = new QRSVG({
|
|
1252
1195
|
...this.options,
|
|
1253
|
-
width:
|
|
1254
|
-
height:
|
|
1255
|
-
errorCorrectionPercent:
|
|
1196
|
+
width: count,
|
|
1197
|
+
height: count,
|
|
1198
|
+
errorCorrectionPercent: ErrorCorrectionPercents[this.options.qrOptions.errorCorrectionLevel]
|
|
1256
1199
|
}), this.svgDrawingPromise = this.qrSVG.drawQR(this.qr).then((() => {
|
|
1257
1200
|
this.qrSVG?.element && this.extension?.(this.qrSVG.element, this.options);
|
|
1258
1201
|
}));
|
|
@@ -1260,38 +1203,37 @@ let $QRCodeStyling$1$$ = class {
|
|
|
1260
1203
|
}
|
|
1261
1204
|
};
|
|
1262
1205
|
|
|
1263
|
-
var
|
|
1206
|
+
var FileExtension;
|
|
1264
1207
|
|
|
1265
|
-
|
|
1266
|
-
|
|
1208
|
+
(FileExtension = FileExtension || (FileExtension = {})).svg = "svg", FileExtension.png = "png",
|
|
1209
|
+
FileExtension.jpeg = "jpeg", FileExtension.webp = "webp";
|
|
1267
1210
|
|
|
1268
|
-
class
|
|
1269
|
-
constructor(
|
|
1270
|
-
async function
|
|
1271
|
-
if ("string" == typeof
|
|
1272
|
-
let
|
|
1273
|
-
return
|
|
1274
|
-
contentType:
|
|
1275
|
-
data
|
|
1276
|
-
}))))),
|
|
1211
|
+
class QRCodeStyling extends QRCodeStyling$1 {
|
|
1212
|
+
constructor(options) {
|
|
1213
|
+
async function loadImage(buff) {
|
|
1214
|
+
if ("string" == typeof buff) {
|
|
1215
|
+
let pr = imageCache.get(buff);
|
|
1216
|
+
return pr || (pr = fetch(buff).then((res => res.arrayBuffer().then((buff => Buffer.from(buff))).then((async data => ({
|
|
1217
|
+
contentType: res.headers.get("Content-Type") || await fileTypeFromBuffer(data).then((r => r?.mime)),
|
|
1218
|
+
data
|
|
1219
|
+
}))))), imageCache.set(buff, pr), pr);
|
|
1277
1220
|
}
|
|
1278
|
-
return
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
data: $buff$jscomp$1_url$jscomp$24$$
|
|
1221
|
+
return buff = Buffer.from(buff), {
|
|
1222
|
+
contentType: await fileTypeFromBuffer(buff).then((r => r?.mime)),
|
|
1223
|
+
data: buff
|
|
1282
1224
|
};
|
|
1283
1225
|
}
|
|
1284
|
-
let
|
|
1226
|
+
let dom = (new DOMImplementation).createDocument(null, ""), imageCache = new Map;
|
|
1285
1227
|
global.XMLSerializer = XMLSerializer$1, global.DOMParser = DOMParser$1, super({
|
|
1286
|
-
|
|
1287
|
-
document:
|
|
1288
|
-
imageTools:
|
|
1289
|
-
toDataURL:
|
|
1290
|
-
getSize: async
|
|
1291
|
-
data:
|
|
1292
|
-
} : await
|
|
1293
|
-
width: (
|
|
1294
|
-
height:
|
|
1228
|
+
...options,
|
|
1229
|
+
document: options.document || dom,
|
|
1230
|
+
imageTools: options.imageTools || {
|
|
1231
|
+
toDataURL: url => "string" == typeof url && url.startsWith("data:") ? Promise.resolve(url) : loadImage(url).then((({contentType, data}) => `data:${contentType?.replace("application/xml", "image/svg+xml")};base64,${data.toString("base64")}`)),
|
|
1232
|
+
getSize: async data => (({data} = Buffer.isBuffer(options.image) ? {
|
|
1233
|
+
data: options.image
|
|
1234
|
+
} : await loadImage(data)), {
|
|
1235
|
+
width: (data = await sharp(data).metadata()).width,
|
|
1236
|
+
height: data.height
|
|
1295
1237
|
})
|
|
1296
1238
|
}
|
|
1297
1239
|
});
|
|
@@ -1300,5 +1242,5 @@ class $QRCodeStyling$$ extends $QRCodeStyling$1$$ {
|
|
|
1300
1242
|
|
|
1301
1243
|
var browserUtils = void 0;
|
|
1302
1244
|
|
|
1303
|
-
export {
|
|
1245
|
+
export { CornerDotType, CornerSquareType, DotType, ErrorCorrectionPercents, FileExtension, GradientType, ImageMode, QRCodeStyling, ShapeType, browserUtils };
|
|
1304
1246
|
//# sourceMappingURL=qr-code-styling-node.js.map
|