@liquid-js/qr-code-styling 2.1.2 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/figures/cornerDot/QRCornerDot.d.ts +11 -1
- package/lib/figures/cornerSquare/QRCornerSquare.d.ts +6 -0
- package/lib/figures/dot/QRDot.d.ts +5 -0
- package/lib/qr-code-styling-node.js +438 -0
- package/lib/qr-code-styling-node.js.map +1 -1
- package/lib/qr-code-styling.js +1 -1
- package/lib/qr-code-styling.js.map +1 -1
- package/lib/types/index.d.ts +16 -3
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ If you have issues / suggestions / notes / questions, please open an issue or co
|
|
|
56
56
|
imageOptions: {
|
|
57
57
|
crossOrigin: "anonymous",
|
|
58
58
|
margin: 1,
|
|
59
|
-
imageSize: 0.
|
|
59
|
+
imageSize: 0.5
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
|
|
@@ -93,7 +93,7 @@ const qrCode = new QRCodeStyling({
|
|
|
93
93
|
imageOptions: {
|
|
94
94
|
crossOrigin: "anonymous",
|
|
95
95
|
margin: 1,
|
|
96
|
-
imageSize: 0.
|
|
96
|
+
imageSize: 0.5
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BasicFigureDrawArgs, CornerDotType, DrawArgs, RotateFigureArgs } from "../../types";
|
|
2
2
|
export declare class QRCornerDot {
|
|
3
3
|
_element?: SVGElement;
|
|
4
4
|
_svg: SVGElement;
|
|
@@ -13,6 +13,16 @@ export declare class QRCornerDot {
|
|
|
13
13
|
_rotateFigure({ x, y, size, rotation, draw }: RotateFigureArgs): void;
|
|
14
14
|
_basicDot(args: BasicFigureDrawArgs): void;
|
|
15
15
|
_basicSquare(args: BasicFigureDrawArgs): void;
|
|
16
|
+
_basicHeart(args: BasicFigureDrawArgs): void;
|
|
17
|
+
_basicRounded(args: BasicFigureDrawArgs): void;
|
|
18
|
+
_basicClassy(args: BasicFigureDrawArgs): void;
|
|
19
|
+
_basicOutpoint(args: BasicFigureDrawArgs): void;
|
|
20
|
+
_basicInpoint(args: BasicFigureDrawArgs): void;
|
|
16
21
|
_drawDot({ x, y, size, rotation }: DrawArgs): void;
|
|
17
22
|
_drawSquare({ x, y, size, rotation }: DrawArgs): void;
|
|
23
|
+
_drawHeart({ x, y, size, rotation }: DrawArgs): void;
|
|
24
|
+
_drawRounded({ x, y, size, rotation }: DrawArgs): void;
|
|
25
|
+
_drawClassy({ x, y, size, rotation }: DrawArgs): void;
|
|
26
|
+
_drawInpoint({ x, y, size, rotation }: DrawArgs): void;
|
|
27
|
+
_drawOutpoint({ x, y, size, rotation }: DrawArgs): void;
|
|
18
28
|
}
|
|
@@ -14,7 +14,13 @@ export declare class QRCornerSquare {
|
|
|
14
14
|
_basicDot(args: BasicFigureDrawArgs): void;
|
|
15
15
|
_basicSquare(args: BasicFigureDrawArgs): void;
|
|
16
16
|
_basicExtraRounded(args: BasicFigureDrawArgs): void;
|
|
17
|
+
_basicClassy(args: BasicFigureDrawArgs): void;
|
|
18
|
+
_basicOutpoint(args: BasicFigureDrawArgs): void;
|
|
19
|
+
_basicInpoint(args: BasicFigureDrawArgs): void;
|
|
17
20
|
_drawDot({ x, y, size, rotation }: DrawArgs): void;
|
|
18
21
|
_drawSquare({ x, y, size, rotation }: DrawArgs): void;
|
|
19
22
|
_drawExtraRounded({ x, y, size, rotation }: DrawArgs): void;
|
|
23
|
+
_drawClassy({ x, y, size, rotation }: DrawArgs): void;
|
|
24
|
+
_drawOutpoint({ x, y, size, rotation }: DrawArgs): void;
|
|
25
|
+
_drawInpoint({ x, y, size, rotation }: DrawArgs): void;
|
|
20
26
|
}
|
|
@@ -18,8 +18,13 @@ export declare class QRDot {
|
|
|
18
18
|
_basicCornerExtraRounded(args: BasicFigureDrawArgs): void;
|
|
19
19
|
_basicCornersRounded(args: BasicFigureDrawArgs): void;
|
|
20
20
|
_drawDot({ x, y, size }: DrawArgs): void;
|
|
21
|
+
_drawRandomDot({ x, y, size }: DrawArgs): void;
|
|
21
22
|
_drawSquare({ x, y, size }: DrawArgs): void;
|
|
23
|
+
_drawSmallSquare({ x, y, size }: DrawArgs): void;
|
|
24
|
+
_drawDiamond({ x, y, size }: DrawArgs): void;
|
|
22
25
|
_drawRounded({ x, y, size, getNeighbor }: DrawArgs): void;
|
|
26
|
+
_drawVerticalLines({ x, y, size, getNeighbor }: DrawArgs): void;
|
|
27
|
+
_drawHorizontalLines({ x, y, size, getNeighbor }: DrawArgs): void;
|
|
23
28
|
_drawExtraRounded({ x, y, size, getNeighbor }: DrawArgs): void;
|
|
24
29
|
_drawClassy({ x, y, size, getNeighbor }: DrawArgs): void;
|
|
25
30
|
_drawClassyRounded({ x, y, size, getNeighbor }: DrawArgs): void;
|
|
@@ -6,22 +6,35 @@ import qrcode from 'qrcode-generator';
|
|
|
6
6
|
var DotType;
|
|
7
7
|
(function (DotType) {
|
|
8
8
|
DotType["dots"] = "dots";
|
|
9
|
+
DotType["randomDots"] = "random-dots";
|
|
9
10
|
DotType["rounded"] = "rounded";
|
|
11
|
+
DotType["verticalLines"] = "vertical-lines";
|
|
12
|
+
DotType["horizontalLines"] = "horizontal-lines";
|
|
10
13
|
DotType["classy"] = "classy";
|
|
11
14
|
DotType["classyRounded"] = "classy-rounded";
|
|
12
15
|
DotType["square"] = "square";
|
|
16
|
+
DotType["smallSquare"] = "small-square";
|
|
13
17
|
DotType["extraRounded"] = "extra-rounded";
|
|
18
|
+
DotType["diamond"] = "diamond";
|
|
14
19
|
})(DotType || (DotType = {}));
|
|
15
20
|
var CornerDotType;
|
|
16
21
|
(function (CornerDotType) {
|
|
17
22
|
CornerDotType["dot"] = "dot";
|
|
18
23
|
CornerDotType["square"] = "square";
|
|
24
|
+
CornerDotType["heart"] = "heart";
|
|
25
|
+
CornerDotType["extraRounded"] = "extra-rounded";
|
|
26
|
+
CornerDotType["classy"] = "classy";
|
|
27
|
+
CornerDotType["outpoint"] = "outpoint";
|
|
28
|
+
CornerDotType["inpoint"] = "inpoint";
|
|
19
29
|
})(CornerDotType || (CornerDotType = {}));
|
|
20
30
|
var CornerSquareType;
|
|
21
31
|
(function (CornerSquareType) {
|
|
22
32
|
CornerSquareType["dot"] = "dot";
|
|
23
33
|
CornerSquareType["square"] = "square";
|
|
24
34
|
CornerSquareType["extraRounded"] = "extra-rounded";
|
|
35
|
+
CornerSquareType["classy"] = "classy";
|
|
36
|
+
CornerSquareType["outpoint"] = "outpoint";
|
|
37
|
+
CornerSquareType["inpoint"] = "inpoint";
|
|
25
38
|
})(CornerSquareType || (CornerSquareType = {}));
|
|
26
39
|
var GradientType;
|
|
27
40
|
(function (GradientType) {
|
|
@@ -199,6 +212,21 @@ class QRCornerDot {
|
|
|
199
212
|
case CornerDotType.square:
|
|
200
213
|
drawFunction = this._drawSquare;
|
|
201
214
|
break;
|
|
215
|
+
case CornerDotType.heart:
|
|
216
|
+
drawFunction = this._drawHeart;
|
|
217
|
+
break;
|
|
218
|
+
case CornerDotType.extraRounded:
|
|
219
|
+
drawFunction = this._drawRounded;
|
|
220
|
+
break;
|
|
221
|
+
case CornerDotType.classy:
|
|
222
|
+
drawFunction = this._drawClassy;
|
|
223
|
+
break;
|
|
224
|
+
case CornerDotType.inpoint:
|
|
225
|
+
drawFunction = this._drawInpoint;
|
|
226
|
+
break;
|
|
227
|
+
case CornerDotType.outpoint:
|
|
228
|
+
drawFunction = this._drawOutpoint;
|
|
229
|
+
break;
|
|
202
230
|
case CornerDotType.dot:
|
|
203
231
|
default:
|
|
204
232
|
drawFunction = this._drawDot;
|
|
@@ -236,12 +264,237 @@ class QRCornerDot {
|
|
|
236
264
|
}
|
|
237
265
|
});
|
|
238
266
|
}
|
|
267
|
+
_basicHeart(args) {
|
|
268
|
+
const { size, x, y } = args;
|
|
269
|
+
this._element = this._document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
270
|
+
const path = [
|
|
271
|
+
"M",
|
|
272
|
+
0.925,
|
|
273
|
+
0.3538125,
|
|
274
|
+
"c",
|
|
275
|
+
0,
|
|
276
|
+
0.0325869,
|
|
277
|
+
-0.0054931,
|
|
278
|
+
0.0644619,
|
|
279
|
+
-0.0164688,
|
|
280
|
+
0.095625,
|
|
281
|
+
"S",
|
|
282
|
+
0.87825,
|
|
283
|
+
0.5147812,
|
|
284
|
+
0.850625,
|
|
285
|
+
0.5519688,
|
|
286
|
+
"C",
|
|
287
|
+
0.823,
|
|
288
|
+
0.5891563,
|
|
289
|
+
0.7858125,
|
|
290
|
+
0.631125,
|
|
291
|
+
0.7390625,
|
|
292
|
+
0.677875,
|
|
293
|
+
"S",
|
|
294
|
+
0.6331632,
|
|
295
|
+
0.7802256,
|
|
296
|
+
0.561625,
|
|
297
|
+
0.8446875,
|
|
298
|
+
"L",
|
|
299
|
+
0.5,
|
|
300
|
+
0.8999375,
|
|
301
|
+
"l",
|
|
302
|
+
-0.061625,
|
|
303
|
+
-0.05525,
|
|
304
|
+
"C",
|
|
305
|
+
0.3668368,
|
|
306
|
+
0.7802256,
|
|
307
|
+
0.3076875,
|
|
308
|
+
0.724625,
|
|
309
|
+
0.2609375,
|
|
310
|
+
0.677875,
|
|
311
|
+
"S",
|
|
312
|
+
0.177,
|
|
313
|
+
0.5891563,
|
|
314
|
+
0.149375,
|
|
315
|
+
0.5519688,
|
|
316
|
+
"S",
|
|
317
|
+
0.1024444,
|
|
318
|
+
0.4806007,
|
|
319
|
+
0.0914688,
|
|
320
|
+
0.4494375,
|
|
321
|
+
"S",
|
|
322
|
+
0.075,
|
|
323
|
+
0.3863994,
|
|
324
|
+
0.075,
|
|
325
|
+
0.3538125,
|
|
326
|
+
"C",
|
|
327
|
+
0.075,
|
|
328
|
+
0.2872256,
|
|
329
|
+
0.0973125,
|
|
330
|
+
0.231625,
|
|
331
|
+
0.1419375,
|
|
332
|
+
0.187,
|
|
333
|
+
"S",
|
|
334
|
+
0.2421631,
|
|
335
|
+
0.1200625,
|
|
336
|
+
0.30875,
|
|
337
|
+
0.1200625,
|
|
338
|
+
"c",
|
|
339
|
+
0.0368369,
|
|
340
|
+
0,
|
|
341
|
+
0.0718994,
|
|
342
|
+
0.0077881,
|
|
343
|
+
0.1051875,
|
|
344
|
+
0.023375,
|
|
345
|
+
"S",
|
|
346
|
+
0.4759131,
|
|
347
|
+
0.1809756,
|
|
348
|
+
0.5,
|
|
349
|
+
0.2093125,
|
|
350
|
+
"c",
|
|
351
|
+
0.0240868,
|
|
352
|
+
-0.0283369,
|
|
353
|
+
0.0527744,
|
|
354
|
+
-0.0502881,
|
|
355
|
+
0.0860625,
|
|
356
|
+
-0.065875,
|
|
357
|
+
"c",
|
|
358
|
+
0.0332882,
|
|
359
|
+
-0.0155869,
|
|
360
|
+
0.0683507,
|
|
361
|
+
-0.023375,
|
|
362
|
+
0.1051875,
|
|
363
|
+
-0.023375,
|
|
364
|
+
"c",
|
|
365
|
+
0.0665869,
|
|
366
|
+
0,
|
|
367
|
+
0.1221875,
|
|
368
|
+
0.0223125,
|
|
369
|
+
0.1668125,
|
|
370
|
+
0.0669375,
|
|
371
|
+
"S",
|
|
372
|
+
0.925,
|
|
373
|
+
0.2872256,
|
|
374
|
+
0.925,
|
|
375
|
+
0.3538125,
|
|
376
|
+
"z"
|
|
377
|
+
];
|
|
378
|
+
let move = false;
|
|
379
|
+
let i = 0;
|
|
380
|
+
this._element.setAttribute("d", path
|
|
381
|
+
.map((v) => {
|
|
382
|
+
if (typeof v == "string") {
|
|
383
|
+
i = 0;
|
|
384
|
+
move = v.toUpperCase() == v;
|
|
385
|
+
return v;
|
|
386
|
+
}
|
|
387
|
+
i++;
|
|
388
|
+
v = v * size;
|
|
389
|
+
if (move) {
|
|
390
|
+
v += i % 2 == 1 ? x : y;
|
|
391
|
+
}
|
|
392
|
+
return v.toFixed(5);
|
|
393
|
+
})
|
|
394
|
+
.join(" "));
|
|
395
|
+
}
|
|
396
|
+
_basicRounded(args) {
|
|
397
|
+
const { size, x, y } = args;
|
|
398
|
+
this._rotateFigure({
|
|
399
|
+
...args,
|
|
400
|
+
draw: () => {
|
|
401
|
+
this._element = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
402
|
+
this._element.setAttribute("x", String(x));
|
|
403
|
+
this._element.setAttribute("y", String(y));
|
|
404
|
+
this._element.setAttribute("width", String(size));
|
|
405
|
+
this._element.setAttribute("height", String(size));
|
|
406
|
+
this._element.setAttribute("rx", String(size / 4));
|
|
407
|
+
this._element.setAttribute("ry", String(size / 4));
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
_basicClassy(args) {
|
|
412
|
+
const { size, x, y } = args;
|
|
413
|
+
const dotSize = size / 7;
|
|
414
|
+
this._rotateFigure({
|
|
415
|
+
...args,
|
|
416
|
+
draw: () => {
|
|
417
|
+
this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
418
|
+
this._element.setAttribute("clip-rule", "evenodd");
|
|
419
|
+
this._element.setAttribute("d", `M ${x} ${y + 2.5 * dotSize}` +
|
|
420
|
+
`v ${2 * dotSize}` +
|
|
421
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${dotSize * 2.5} ${dotSize * 2.5}` +
|
|
422
|
+
`h ${4.5 * dotSize}` +
|
|
423
|
+
`v ${-4.5 * dotSize}` +
|
|
424
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${-dotSize * 2.5} ${-dotSize * 2.5}` +
|
|
425
|
+
`h ${-2 * dotSize}` +
|
|
426
|
+
`H ${x}` +
|
|
427
|
+
`z`);
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
_basicOutpoint(args) {
|
|
432
|
+
const { size, x, y } = args;
|
|
433
|
+
const dotSize = size;
|
|
434
|
+
this._rotateFigure({
|
|
435
|
+
...args,
|
|
436
|
+
draw: () => {
|
|
437
|
+
this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
438
|
+
this._element.setAttribute("clip-rule", "evenodd");
|
|
439
|
+
this._element.setAttribute("d", `M ${x} ${y + dotSize / 2}` +
|
|
440
|
+
`v ${dotSize / 4}` +
|
|
441
|
+
`a ${dotSize / 4}, ${dotSize / 4} 0 0 0 ${dotSize / 4}, ${dotSize / 4}` +
|
|
442
|
+
`h ${dotSize / 2}` +
|
|
443
|
+
`a ${dotSize / 4}, ${dotSize / 4} 0 0 0 ${dotSize / 4}, ${-dotSize / 4}` +
|
|
444
|
+
`v ${-dotSize / 2}` +
|
|
445
|
+
`a ${dotSize / 4}, ${dotSize / 4} 0 0 0 ${-dotSize / 4}, ${-dotSize / 4}` +
|
|
446
|
+
`h ${(-dotSize / 4) * 3}` +
|
|
447
|
+
`z`);
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
_basicInpoint(args) {
|
|
452
|
+
const { size, x, y } = args;
|
|
453
|
+
const dotSize = size;
|
|
454
|
+
this._rotateFigure({
|
|
455
|
+
...args,
|
|
456
|
+
draw: () => {
|
|
457
|
+
this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
458
|
+
this._element.setAttribute("clip-rule", "evenodd");
|
|
459
|
+
this._element.setAttribute("d", `M ${x} ${y + dotSize / 2}` +
|
|
460
|
+
`v ${dotSize / 4}` +
|
|
461
|
+
`a ${dotSize / 4}, ${dotSize / 4} 0 0 0 ${dotSize / 4}, ${dotSize / 4}` +
|
|
462
|
+
`h ${(dotSize / 4) * 3}` +
|
|
463
|
+
`v ${(-dotSize / 4) * 3}` +
|
|
464
|
+
`a ${dotSize / 4}, ${dotSize / 4} 0 0 0 ${-dotSize / 4}, ${-dotSize / 4}` +
|
|
465
|
+
`h ${-dotSize / 2}` +
|
|
466
|
+
`a ${dotSize / 4}, ${dotSize / 4} 0 0 0 ${-dotSize / 4}, ${dotSize / 4}` +
|
|
467
|
+
`z`);
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
}
|
|
239
471
|
_drawDot({ x, y, size, rotation }) {
|
|
240
472
|
this._basicDot({ x, y, size, rotation });
|
|
241
473
|
}
|
|
242
474
|
_drawSquare({ x, y, size, rotation }) {
|
|
243
475
|
this._basicSquare({ x, y, size, rotation });
|
|
244
476
|
}
|
|
477
|
+
_drawHeart({ x, y, size, rotation }) {
|
|
478
|
+
const scaleFactor = 0.2;
|
|
479
|
+
this._basicHeart({
|
|
480
|
+
x: x - (scaleFactor * size) / 2,
|
|
481
|
+
y: y - (scaleFactor * size) / 2,
|
|
482
|
+
size: size * (1 + scaleFactor),
|
|
483
|
+
rotation
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
_drawRounded({ x, y, size, rotation }) {
|
|
487
|
+
this._basicRounded({ x, y, size, rotation });
|
|
488
|
+
}
|
|
489
|
+
_drawClassy({ x, y, size, rotation }) {
|
|
490
|
+
this._basicClassy({ x, y, size, rotation });
|
|
491
|
+
}
|
|
492
|
+
_drawInpoint({ x, y, size, rotation }) {
|
|
493
|
+
this._basicInpoint({ x, y, size, rotation });
|
|
494
|
+
}
|
|
495
|
+
_drawOutpoint({ x, y, size, rotation }) {
|
|
496
|
+
this._basicOutpoint({ x, y, size, rotation });
|
|
497
|
+
}
|
|
245
498
|
}
|
|
246
499
|
|
|
247
500
|
class QRCornerSquare {
|
|
@@ -260,6 +513,15 @@ class QRCornerSquare {
|
|
|
260
513
|
case CornerSquareType.extraRounded:
|
|
261
514
|
drawFunction = this._drawExtraRounded;
|
|
262
515
|
break;
|
|
516
|
+
case CornerSquareType.classy:
|
|
517
|
+
drawFunction = this._drawClassy;
|
|
518
|
+
break;
|
|
519
|
+
case CornerSquareType.outpoint:
|
|
520
|
+
drawFunction = this._drawOutpoint;
|
|
521
|
+
break;
|
|
522
|
+
case CornerSquareType.inpoint:
|
|
523
|
+
drawFunction = this._drawInpoint;
|
|
524
|
+
break;
|
|
263
525
|
case CornerSquareType.dot:
|
|
264
526
|
default:
|
|
265
527
|
drawFunction = this._drawDot;
|
|
@@ -340,6 +602,90 @@ class QRCornerSquare {
|
|
|
340
602
|
}
|
|
341
603
|
});
|
|
342
604
|
}
|
|
605
|
+
_basicClassy(args) {
|
|
606
|
+
const { size, x, y } = args;
|
|
607
|
+
const dotSize = size / 7;
|
|
608
|
+
this._rotateFigure({
|
|
609
|
+
...args,
|
|
610
|
+
draw: () => {
|
|
611
|
+
this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
612
|
+
this._element.setAttribute("clip-rule", "evenodd");
|
|
613
|
+
this._element.setAttribute("d", `M ${x} ${y + 2.5 * dotSize}` +
|
|
614
|
+
`v ${2 * dotSize}` +
|
|
615
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${dotSize * 2.5} ${dotSize * 2.5}` +
|
|
616
|
+
`h ${4.5 * dotSize}` +
|
|
617
|
+
`v ${-4.5 * dotSize}` +
|
|
618
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${-dotSize * 2.5} ${-dotSize * 2.5}` +
|
|
619
|
+
`h ${-2 * dotSize}` +
|
|
620
|
+
`H ${x}` +
|
|
621
|
+
`z` +
|
|
622
|
+
`M ${x + 2.5 * dotSize} ${y + dotSize}` +
|
|
623
|
+
`h ${2 * dotSize}` +
|
|
624
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${dotSize * 1.5} ${dotSize * 1.5}` +
|
|
625
|
+
`v ${3.5 * dotSize}` +
|
|
626
|
+
`h ${-3.5 * dotSize}` +
|
|
627
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${-dotSize * 1.5} ${-dotSize * 1.5}` +
|
|
628
|
+
`v ${-3.5 * dotSize}` +
|
|
629
|
+
`z`);
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
_basicOutpoint(args) {
|
|
634
|
+
const { size, x, y } = args;
|
|
635
|
+
const dotSize = size / 7;
|
|
636
|
+
this._rotateFigure({
|
|
637
|
+
...args,
|
|
638
|
+
draw: () => {
|
|
639
|
+
this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
640
|
+
this._element.setAttribute("clip-rule", "evenodd");
|
|
641
|
+
this._element.setAttribute("d", `M ${x} ${y + 2.5 * dotSize}` +
|
|
642
|
+
`v ${2 * dotSize}` +
|
|
643
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${dotSize * 2.5} ${dotSize * 2.5}` +
|
|
644
|
+
`h ${2 * dotSize}` +
|
|
645
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${dotSize * 2.5} ${-dotSize * 2.5}` +
|
|
646
|
+
`v ${-2 * dotSize}` +
|
|
647
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${-dotSize * 2.5} ${-dotSize * 2.5}` +
|
|
648
|
+
`h ${-2 * dotSize}` +
|
|
649
|
+
`a ${dotSize} ${2.5 * dotSize}, 0, 0, 0, ${-dotSize * 2.5} ${dotSize * 2.5}` +
|
|
650
|
+
`M ${x + 2.5 * dotSize} ${y + dotSize}` +
|
|
651
|
+
`h ${2 * dotSize}` +
|
|
652
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${dotSize * 1.5} ${dotSize * 1.5}` +
|
|
653
|
+
`v ${2 * dotSize}` +
|
|
654
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${-dotSize * 1.5} ${dotSize * 1.5}` +
|
|
655
|
+
`h ${-2 * dotSize}` +
|
|
656
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${-dotSize * 1.5} ${-dotSize * 1.5}` +
|
|
657
|
+
`v ${-2 * dotSize}` +
|
|
658
|
+
`l 0 ${-dotSize * 1.5}`);
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
_basicInpoint(args) {
|
|
663
|
+
const { size, x, y } = args;
|
|
664
|
+
const dotSize = size / 7;
|
|
665
|
+
this._rotateFigure({
|
|
666
|
+
...args,
|
|
667
|
+
draw: () => {
|
|
668
|
+
this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
669
|
+
this._element.setAttribute("clip-rule", "evenodd");
|
|
670
|
+
this._element.setAttribute("d", `M ${x} ${y + 2.5 * dotSize}` +
|
|
671
|
+
`v ${2 * dotSize}` +
|
|
672
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${dotSize * 2.5} ${dotSize * 2.5}` +
|
|
673
|
+
`h ${4.5 * dotSize}` +
|
|
674
|
+
`v ${-4.5 * dotSize}` +
|
|
675
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${-dotSize * 2.5} ${-dotSize * 2.5}` +
|
|
676
|
+
`h ${-2 * dotSize}` +
|
|
677
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${-dotSize * 2.5} ${dotSize * 2.5}` +
|
|
678
|
+
`M ${x + 2.5 * dotSize} ${y + dotSize}` +
|
|
679
|
+
`h ${2 * dotSize}` +
|
|
680
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${dotSize * 1.5} ${dotSize * 1.5}` +
|
|
681
|
+
`v ${3.5 * dotSize}` +
|
|
682
|
+
`h ${-3.5 * dotSize}` +
|
|
683
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${-dotSize * 1.5} ${-dotSize * 1.5}` +
|
|
684
|
+
`v ${-2 * dotSize}` +
|
|
685
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${dotSize * 1.5} ${-dotSize * 1.5}`);
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
}
|
|
343
689
|
_drawDot({ x, y, size, rotation }) {
|
|
344
690
|
this._basicDot({ x, y, size, rotation });
|
|
345
691
|
}
|
|
@@ -349,6 +695,15 @@ class QRCornerSquare {
|
|
|
349
695
|
_drawExtraRounded({ x, y, size, rotation }) {
|
|
350
696
|
this._basicExtraRounded({ x, y, size, rotation });
|
|
351
697
|
}
|
|
698
|
+
_drawClassy({ x, y, size, rotation }) {
|
|
699
|
+
this._basicClassy({ x, y, size, rotation });
|
|
700
|
+
}
|
|
701
|
+
_drawOutpoint({ x, y, size, rotation }) {
|
|
702
|
+
this._basicOutpoint({ x, y, size, rotation });
|
|
703
|
+
}
|
|
704
|
+
_drawInpoint({ x, y, size, rotation }) {
|
|
705
|
+
this._basicInpoint({ x, y, size, rotation });
|
|
706
|
+
}
|
|
352
707
|
}
|
|
353
708
|
|
|
354
709
|
class QRDot {
|
|
@@ -364,6 +719,9 @@ class QRDot {
|
|
|
364
719
|
case DotType.dots:
|
|
365
720
|
drawFunction = this._drawDot;
|
|
366
721
|
break;
|
|
722
|
+
case DotType.randomDots:
|
|
723
|
+
drawFunction = this._drawRandomDot;
|
|
724
|
+
break;
|
|
367
725
|
case DotType.classy:
|
|
368
726
|
drawFunction = this._drawClassy;
|
|
369
727
|
break;
|
|
@@ -373,9 +731,21 @@ class QRDot {
|
|
|
373
731
|
case DotType.rounded:
|
|
374
732
|
drawFunction = this._drawRounded;
|
|
375
733
|
break;
|
|
734
|
+
case DotType.verticalLines:
|
|
735
|
+
drawFunction = this._drawVerticalLines;
|
|
736
|
+
break;
|
|
737
|
+
case DotType.horizontalLines:
|
|
738
|
+
drawFunction = this._drawHorizontalLines;
|
|
739
|
+
break;
|
|
376
740
|
case DotType.extraRounded:
|
|
377
741
|
drawFunction = this._drawExtraRounded;
|
|
378
742
|
break;
|
|
743
|
+
case DotType.diamond:
|
|
744
|
+
drawFunction = this._drawDiamond;
|
|
745
|
+
break;
|
|
746
|
+
case DotType.smallSquare:
|
|
747
|
+
drawFunction = this._drawSmallSquare;
|
|
748
|
+
break;
|
|
379
749
|
case DotType.square:
|
|
380
750
|
default:
|
|
381
751
|
drawFunction = this._drawSquare;
|
|
@@ -479,9 +849,23 @@ class QRDot {
|
|
|
479
849
|
_drawDot({ x, y, size }) {
|
|
480
850
|
this._basicDot({ x, y, size, rotation: 0 });
|
|
481
851
|
}
|
|
852
|
+
_drawRandomDot({ x, y, size }) {
|
|
853
|
+
const randomFactor = Math.random() * (1 - 0.75) + 0.75;
|
|
854
|
+
this._basicDot({ x, y, size: size * randomFactor, rotation: 0 });
|
|
855
|
+
}
|
|
482
856
|
_drawSquare({ x, y, size }) {
|
|
483
857
|
this._basicSquare({ x, y, size, rotation: 0 });
|
|
484
858
|
}
|
|
859
|
+
_drawSmallSquare({ x, y, size }) {
|
|
860
|
+
const originalSize = size;
|
|
861
|
+
size = originalSize * 0.7;
|
|
862
|
+
x = x + originalSize * 0.15;
|
|
863
|
+
y = y + originalSize * 0.15;
|
|
864
|
+
this._basicSquare({ x, y, size, rotation: 0 });
|
|
865
|
+
}
|
|
866
|
+
_drawDiamond({ x, y, size }) {
|
|
867
|
+
this._basicSquare({ x, y, size, rotation: Math.PI / 4 });
|
|
868
|
+
}
|
|
485
869
|
_drawRounded({ x, y, size, getNeighbor }) {
|
|
486
870
|
const leftNeighbor = getNeighbor ? +getNeighbor(-1, 0) : 0;
|
|
487
871
|
const rightNeighbor = getNeighbor ? +getNeighbor(1, 0) : 0;
|
|
@@ -525,6 +909,60 @@ class QRDot {
|
|
|
525
909
|
return;
|
|
526
910
|
}
|
|
527
911
|
}
|
|
912
|
+
_drawVerticalLines({ x, y, size, getNeighbor }) {
|
|
913
|
+
const leftNeighbor = getNeighbor ? +getNeighbor(-1, 0) : 0;
|
|
914
|
+
const rightNeighbor = getNeighbor ? +getNeighbor(1, 0) : 0;
|
|
915
|
+
const topNeighbor = getNeighbor ? +getNeighbor(0, -1) : 0;
|
|
916
|
+
const bottomNeighbor = getNeighbor ? +getNeighbor(0, 1) : 0;
|
|
917
|
+
const neighborsCount = leftNeighbor + rightNeighbor + topNeighbor + bottomNeighbor;
|
|
918
|
+
if (neighborsCount === 0 ||
|
|
919
|
+
(leftNeighbor && !(topNeighbor || bottomNeighbor)) ||
|
|
920
|
+
(rightNeighbor && !(topNeighbor || bottomNeighbor))) {
|
|
921
|
+
this._basicDot({ x, y, size, rotation: 0 });
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
if (topNeighbor && bottomNeighbor) {
|
|
925
|
+
this._basicSquare({ x, y, size, rotation: 0 });
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
if (topNeighbor && !bottomNeighbor) {
|
|
929
|
+
const rotation = Math.PI / 2;
|
|
930
|
+
this._basicSideRounded({ x, y, size, rotation });
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
if (bottomNeighbor && !topNeighbor) {
|
|
934
|
+
const rotation = -Math.PI / 2;
|
|
935
|
+
this._basicSideRounded({ x, y, size, rotation });
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
_drawHorizontalLines({ x, y, size, getNeighbor }) {
|
|
940
|
+
const leftNeighbor = getNeighbor ? +getNeighbor(-1, 0) : 0;
|
|
941
|
+
const rightNeighbor = getNeighbor ? +getNeighbor(1, 0) : 0;
|
|
942
|
+
const topNeighbor = getNeighbor ? +getNeighbor(0, -1) : 0;
|
|
943
|
+
const bottomNeighbor = getNeighbor ? +getNeighbor(0, 1) : 0;
|
|
944
|
+
const neighborsCount = leftNeighbor + rightNeighbor + topNeighbor + bottomNeighbor;
|
|
945
|
+
if (neighborsCount === 0 ||
|
|
946
|
+
(topNeighbor && !(leftNeighbor || rightNeighbor)) ||
|
|
947
|
+
(bottomNeighbor && !(leftNeighbor || rightNeighbor))) {
|
|
948
|
+
this._basicDot({ x, y, size, rotation: 0 });
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
if (leftNeighbor && rightNeighbor) {
|
|
952
|
+
this._basicSquare({ x, y, size, rotation: 0 });
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
if (leftNeighbor && !rightNeighbor) {
|
|
956
|
+
const rotation = 0;
|
|
957
|
+
this._basicSideRounded({ x, y, size, rotation });
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
if (rightNeighbor && !leftNeighbor) {
|
|
961
|
+
const rotation = Math.PI;
|
|
962
|
+
this._basicSideRounded({ x, y, size, rotation });
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
528
966
|
_drawExtraRounded({ x, y, size, getNeighbor }) {
|
|
529
967
|
const leftNeighbor = getNeighbor ? +getNeighbor(-1, 0) : 0;
|
|
530
968
|
const rightNeighbor = getNeighbor ? +getNeighbor(1, 0) : 0;
|