@liquid-js/qr-code-styling 2.1.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +454 -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,253 @@ 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.3569803,
|
|
274
|
+
"c",
|
|
275
|
+
0,
|
|
276
|
+
0.0339813,
|
|
277
|
+
-0.0085083,
|
|
278
|
+
0.0595062,
|
|
279
|
+
-0.0170166,
|
|
280
|
+
0.0934875,
|
|
281
|
+
"C",
|
|
282
|
+
0.8994751,
|
|
283
|
+
0.484501,
|
|
284
|
+
0.8740021,
|
|
285
|
+
0.5184824,
|
|
286
|
+
0.8484772,
|
|
287
|
+
0.5524637,
|
|
288
|
+
"C",
|
|
289
|
+
0.8230041,
|
|
290
|
+
0.5950052,
|
|
291
|
+
0.7890228,
|
|
292
|
+
0.6374948,
|
|
293
|
+
0.7380249,
|
|
294
|
+
0.6799845,
|
|
295
|
+
"C",
|
|
296
|
+
0.6954834,
|
|
297
|
+
0.7309824,
|
|
298
|
+
0.6359771,
|
|
299
|
+
0.7819803,
|
|
300
|
+
0.5595062,
|
|
301
|
+
0.8499948,
|
|
302
|
+
"L",
|
|
303
|
+
0.5,
|
|
304
|
+
0.9009928,
|
|
305
|
+
"L",
|
|
306
|
+
0.4404938,
|
|
307
|
+
0.8499948,
|
|
308
|
+
"C",
|
|
309
|
+
0.3640228,
|
|
310
|
+
0.7819803,
|
|
311
|
+
0.3045166,
|
|
312
|
+
0.7309824,
|
|
313
|
+
0.2619751,
|
|
314
|
+
0.6799845,
|
|
315
|
+
"C",
|
|
316
|
+
0.2109772,
|
|
317
|
+
0.6374948,
|
|
318
|
+
0.1769958,
|
|
319
|
+
0.5950052,
|
|
320
|
+
0.1515228,
|
|
321
|
+
0.5524637,
|
|
322
|
+
"C",
|
|
323
|
+
0.1174896,
|
|
324
|
+
0.5184824,
|
|
325
|
+
0.1005249,
|
|
326
|
+
0.484501,
|
|
327
|
+
0.0920166,
|
|
328
|
+
0.4504678,
|
|
329
|
+
"C",
|
|
330
|
+
0.0835083,
|
|
331
|
+
0.4164865,
|
|
332
|
+
0.075,
|
|
333
|
+
0.3909616,
|
|
334
|
+
0.075,
|
|
335
|
+
0.3569803,
|
|
336
|
+
"c",
|
|
337
|
+
0,
|
|
338
|
+
-0.0680145,
|
|
339
|
+
0.0255249,
|
|
340
|
+
-0.1190125,
|
|
341
|
+
0.0680145,
|
|
342
|
+
-0.1700104,
|
|
343
|
+
"c",
|
|
344
|
+
0.0424896,
|
|
345
|
+
-0.0424896,
|
|
346
|
+
0.1019959,
|
|
347
|
+
-0.0679626,
|
|
348
|
+
0.1700104,
|
|
349
|
+
-0.0679626,
|
|
350
|
+
"c",
|
|
351
|
+
0.0339813,
|
|
352
|
+
0,
|
|
353
|
+
0.0679626,
|
|
354
|
+
0.0084564,
|
|
355
|
+
0.1019959,
|
|
356
|
+
0.025473,
|
|
357
|
+
"C",
|
|
358
|
+
0.4490021,
|
|
359
|
+
0.1614969,
|
|
360
|
+
0.4744751,
|
|
361
|
+
0.1869699,
|
|
362
|
+
0.5,
|
|
363
|
+
0.2124948,
|
|
364
|
+
"c",
|
|
365
|
+
0.0255249,
|
|
366
|
+
-0.0255249,
|
|
367
|
+
0.0509979,
|
|
368
|
+
-0.0509979,
|
|
369
|
+
0.0849792,
|
|
370
|
+
-0.0680145,
|
|
371
|
+
"c",
|
|
372
|
+
0.0340332,
|
|
373
|
+
-0.0170166,
|
|
374
|
+
0.0680146,
|
|
375
|
+
-0.025473,
|
|
376
|
+
0.1105042,
|
|
377
|
+
-0.025473,
|
|
378
|
+
"c",
|
|
379
|
+
0.0595062,
|
|
380
|
+
0,
|
|
381
|
+
0.1190125,
|
|
382
|
+
0.025473,
|
|
383
|
+
0.1615021,
|
|
384
|
+
0.0679626,
|
|
385
|
+
"C",
|
|
386
|
+
0.8994751,
|
|
387
|
+
0.2379678,
|
|
388
|
+
0.925,
|
|
389
|
+
0.2889658,
|
|
390
|
+
0.925,
|
|
391
|
+
0.3569803,
|
|
392
|
+
"z"
|
|
393
|
+
];
|
|
394
|
+
let move = false;
|
|
395
|
+
let i = 0;
|
|
396
|
+
this._element.setAttribute("d", path
|
|
397
|
+
.map((v) => {
|
|
398
|
+
if (typeof v == "string") {
|
|
399
|
+
i = 0;
|
|
400
|
+
move = v.toUpperCase() == v;
|
|
401
|
+
return v;
|
|
402
|
+
}
|
|
403
|
+
i++;
|
|
404
|
+
v = v * size;
|
|
405
|
+
if (move) {
|
|
406
|
+
v += i % 2 == 1 ? x : y;
|
|
407
|
+
}
|
|
408
|
+
return v.toFixed(5);
|
|
409
|
+
})
|
|
410
|
+
.join(" "));
|
|
411
|
+
}
|
|
412
|
+
_basicRounded(args) {
|
|
413
|
+
const { size, x, y } = args;
|
|
414
|
+
this._rotateFigure({
|
|
415
|
+
...args,
|
|
416
|
+
draw: () => {
|
|
417
|
+
this._element = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
418
|
+
this._element.setAttribute("x", String(x));
|
|
419
|
+
this._element.setAttribute("y", String(y));
|
|
420
|
+
this._element.setAttribute("width", String(size));
|
|
421
|
+
this._element.setAttribute("height", String(size));
|
|
422
|
+
this._element.setAttribute("rx", String(size / 4));
|
|
423
|
+
this._element.setAttribute("ry", String(size / 4));
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
_basicClassy(args) {
|
|
428
|
+
const { size, x, y } = args;
|
|
429
|
+
const dotSize = size / 7;
|
|
430
|
+
this._rotateFigure({
|
|
431
|
+
...args,
|
|
432
|
+
draw: () => {
|
|
433
|
+
this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
434
|
+
this._element.setAttribute("clip-rule", "evenodd");
|
|
435
|
+
this._element.setAttribute("d", `M ${x} ${y + 2.5 * dotSize}` +
|
|
436
|
+
`v ${2 * dotSize}` +
|
|
437
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${dotSize * 2.5} ${dotSize * 2.5}` +
|
|
438
|
+
`h ${4.5 * dotSize}` +
|
|
439
|
+
`v ${-4.5 * dotSize}` +
|
|
440
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${-dotSize * 2.5} ${-dotSize * 2.5}` +
|
|
441
|
+
`h ${-2 * dotSize}` +
|
|
442
|
+
`H ${x}` +
|
|
443
|
+
`z`);
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
_basicOutpoint(args) {
|
|
448
|
+
const { size, x, y } = args;
|
|
449
|
+
const dotSize = size;
|
|
450
|
+
this._rotateFigure({
|
|
451
|
+
...args,
|
|
452
|
+
draw: () => {
|
|
453
|
+
this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
454
|
+
this._element.setAttribute("clip-rule", "evenodd");
|
|
455
|
+
this._element.setAttribute("d", `M ${x} ${y + dotSize / 2}` +
|
|
456
|
+
`v ${dotSize / 4}` +
|
|
457
|
+
`a ${dotSize / 4}, ${dotSize / 4} 0 0 0 ${dotSize / 4}, ${dotSize / 4}` +
|
|
458
|
+
`h ${dotSize / 2}` +
|
|
459
|
+
`a ${dotSize / 4}, ${dotSize / 4} 0 0 0 ${dotSize / 4}, ${-dotSize / 4}` +
|
|
460
|
+
`v ${-dotSize / 2}` +
|
|
461
|
+
`a ${dotSize / 4}, ${dotSize / 4} 0 0 0 ${-dotSize / 4}, ${-dotSize / 4}` +
|
|
462
|
+
`h ${(-dotSize / 4) * 3}` +
|
|
463
|
+
`z`);
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
_basicInpoint(args) {
|
|
468
|
+
const { size, x, y } = args;
|
|
469
|
+
const dotSize = size;
|
|
470
|
+
this._rotateFigure({
|
|
471
|
+
...args,
|
|
472
|
+
draw: () => {
|
|
473
|
+
this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
474
|
+
this._element.setAttribute("clip-rule", "evenodd");
|
|
475
|
+
this._element.setAttribute("d", `M ${x} ${y + dotSize / 2}` +
|
|
476
|
+
`v ${dotSize / 4}` +
|
|
477
|
+
`a ${dotSize / 4}, ${dotSize / 4} 0 0 0 ${dotSize / 4}, ${dotSize / 4}` +
|
|
478
|
+
`h ${(dotSize / 4) * 3}` +
|
|
479
|
+
`v ${(-dotSize / 4) * 3}` +
|
|
480
|
+
`a ${dotSize / 4}, ${dotSize / 4} 0 0 0 ${-dotSize / 4}, ${-dotSize / 4}` +
|
|
481
|
+
`h ${-dotSize / 2}` +
|
|
482
|
+
`a ${dotSize / 4}, ${dotSize / 4} 0 0 0 ${-dotSize / 4}, ${dotSize / 4}` +
|
|
483
|
+
`z`);
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
}
|
|
239
487
|
_drawDot({ x, y, size, rotation }) {
|
|
240
488
|
this._basicDot({ x, y, size, rotation });
|
|
241
489
|
}
|
|
242
490
|
_drawSquare({ x, y, size, rotation }) {
|
|
243
491
|
this._basicSquare({ x, y, size, rotation });
|
|
244
492
|
}
|
|
493
|
+
_drawHeart({ x, y, size, rotation }) {
|
|
494
|
+
const scaleFactor = 0.2;
|
|
495
|
+
this._basicHeart({
|
|
496
|
+
x: x - (scaleFactor * size) / 2,
|
|
497
|
+
y: y - (scaleFactor * size) / 2,
|
|
498
|
+
size: size * (1 + scaleFactor),
|
|
499
|
+
rotation
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
_drawRounded({ x, y, size, rotation }) {
|
|
503
|
+
this._basicRounded({ x, y, size, rotation });
|
|
504
|
+
}
|
|
505
|
+
_drawClassy({ x, y, size, rotation }) {
|
|
506
|
+
this._basicClassy({ x, y, size, rotation });
|
|
507
|
+
}
|
|
508
|
+
_drawInpoint({ x, y, size, rotation }) {
|
|
509
|
+
this._basicInpoint({ x, y, size, rotation });
|
|
510
|
+
}
|
|
511
|
+
_drawOutpoint({ x, y, size, rotation }) {
|
|
512
|
+
this._basicOutpoint({ x, y, size, rotation });
|
|
513
|
+
}
|
|
245
514
|
}
|
|
246
515
|
|
|
247
516
|
class QRCornerSquare {
|
|
@@ -260,6 +529,15 @@ class QRCornerSquare {
|
|
|
260
529
|
case CornerSquareType.extraRounded:
|
|
261
530
|
drawFunction = this._drawExtraRounded;
|
|
262
531
|
break;
|
|
532
|
+
case CornerSquareType.classy:
|
|
533
|
+
drawFunction = this._drawClassy;
|
|
534
|
+
break;
|
|
535
|
+
case CornerSquareType.outpoint:
|
|
536
|
+
drawFunction = this._drawOutpoint;
|
|
537
|
+
break;
|
|
538
|
+
case CornerSquareType.inpoint:
|
|
539
|
+
drawFunction = this._drawInpoint;
|
|
540
|
+
break;
|
|
263
541
|
case CornerSquareType.dot:
|
|
264
542
|
default:
|
|
265
543
|
drawFunction = this._drawDot;
|
|
@@ -340,6 +618,90 @@ class QRCornerSquare {
|
|
|
340
618
|
}
|
|
341
619
|
});
|
|
342
620
|
}
|
|
621
|
+
_basicClassy(args) {
|
|
622
|
+
const { size, x, y } = args;
|
|
623
|
+
const dotSize = size / 7;
|
|
624
|
+
this._rotateFigure({
|
|
625
|
+
...args,
|
|
626
|
+
draw: () => {
|
|
627
|
+
this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
628
|
+
this._element.setAttribute("clip-rule", "evenodd");
|
|
629
|
+
this._element.setAttribute("d", `M ${x} ${y + 2.5 * dotSize}` +
|
|
630
|
+
`v ${2 * dotSize}` +
|
|
631
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${dotSize * 2.5} ${dotSize * 2.5}` +
|
|
632
|
+
`h ${4.5 * dotSize}` +
|
|
633
|
+
`v ${-4.5 * dotSize}` +
|
|
634
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${-dotSize * 2.5} ${-dotSize * 2.5}` +
|
|
635
|
+
`h ${-2 * dotSize}` +
|
|
636
|
+
`H ${x}` +
|
|
637
|
+
`z` +
|
|
638
|
+
`M ${x + 2.5 * dotSize} ${y + dotSize}` +
|
|
639
|
+
`h ${2 * dotSize}` +
|
|
640
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${dotSize * 1.5} ${dotSize * 1.5}` +
|
|
641
|
+
`v ${3.5 * dotSize}` +
|
|
642
|
+
`h ${-3.5 * dotSize}` +
|
|
643
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${-dotSize * 1.5} ${-dotSize * 1.5}` +
|
|
644
|
+
`v ${-3.5 * dotSize}` +
|
|
645
|
+
`z`);
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
_basicOutpoint(args) {
|
|
650
|
+
const { size, x, y } = args;
|
|
651
|
+
const dotSize = size / 7;
|
|
652
|
+
this._rotateFigure({
|
|
653
|
+
...args,
|
|
654
|
+
draw: () => {
|
|
655
|
+
this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
656
|
+
this._element.setAttribute("clip-rule", "evenodd");
|
|
657
|
+
this._element.setAttribute("d", `M ${x} ${y + 2.5 * dotSize}` +
|
|
658
|
+
`v ${2 * dotSize}` +
|
|
659
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${dotSize * 2.5} ${dotSize * 2.5}` +
|
|
660
|
+
`h ${2 * dotSize}` +
|
|
661
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${dotSize * 2.5} ${-dotSize * 2.5}` +
|
|
662
|
+
`v ${-2 * dotSize}` +
|
|
663
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${-dotSize * 2.5} ${-dotSize * 2.5}` +
|
|
664
|
+
`h ${-2 * dotSize}` +
|
|
665
|
+
`a ${dotSize} ${2.5 * dotSize}, 0, 0, 0, ${-dotSize * 2.5} ${dotSize * 2.5}` +
|
|
666
|
+
`M ${x + 2.5 * dotSize} ${y + dotSize}` +
|
|
667
|
+
`h ${2 * dotSize}` +
|
|
668
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${dotSize * 1.5} ${dotSize * 1.5}` +
|
|
669
|
+
`v ${2 * dotSize}` +
|
|
670
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${-dotSize * 1.5} ${dotSize * 1.5}` +
|
|
671
|
+
`h ${-2 * dotSize}` +
|
|
672
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${-dotSize * 1.5} ${-dotSize * 1.5}` +
|
|
673
|
+
`v ${-2 * dotSize}` +
|
|
674
|
+
`l 0 ${-dotSize * 1.5}`);
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
_basicInpoint(args) {
|
|
679
|
+
const { size, x, y } = args;
|
|
680
|
+
const dotSize = size / 7;
|
|
681
|
+
this._rotateFigure({
|
|
682
|
+
...args,
|
|
683
|
+
draw: () => {
|
|
684
|
+
this._element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
685
|
+
this._element.setAttribute("clip-rule", "evenodd");
|
|
686
|
+
this._element.setAttribute("d", `M ${x} ${y + 2.5 * dotSize}` +
|
|
687
|
+
`v ${2 * dotSize}` +
|
|
688
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${dotSize * 2.5} ${dotSize * 2.5}` +
|
|
689
|
+
`h ${4.5 * dotSize}` +
|
|
690
|
+
`v ${-4.5 * dotSize}` +
|
|
691
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${-dotSize * 2.5} ${-dotSize * 2.5}` +
|
|
692
|
+
`h ${-2 * dotSize}` +
|
|
693
|
+
`a ${2.5 * dotSize} ${2.5 * dotSize}, 0, 0, 0, ${-dotSize * 2.5} ${dotSize * 2.5}` +
|
|
694
|
+
`M ${x + 2.5 * dotSize} ${y + dotSize}` +
|
|
695
|
+
`h ${2 * dotSize}` +
|
|
696
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${dotSize * 1.5} ${dotSize * 1.5}` +
|
|
697
|
+
`v ${3.5 * dotSize}` +
|
|
698
|
+
`h ${-3.5 * dotSize}` +
|
|
699
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${-dotSize * 1.5} ${-dotSize * 1.5}` +
|
|
700
|
+
`v ${-2 * dotSize}` +
|
|
701
|
+
`a ${1.5 * dotSize} ${1.5 * dotSize}, 0, 0, 1, ${dotSize * 1.5} ${-dotSize * 1.5}`);
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
}
|
|
343
705
|
_drawDot({ x, y, size, rotation }) {
|
|
344
706
|
this._basicDot({ x, y, size, rotation });
|
|
345
707
|
}
|
|
@@ -349,6 +711,15 @@ class QRCornerSquare {
|
|
|
349
711
|
_drawExtraRounded({ x, y, size, rotation }) {
|
|
350
712
|
this._basicExtraRounded({ x, y, size, rotation });
|
|
351
713
|
}
|
|
714
|
+
_drawClassy({ x, y, size, rotation }) {
|
|
715
|
+
this._basicClassy({ x, y, size, rotation });
|
|
716
|
+
}
|
|
717
|
+
_drawOutpoint({ x, y, size, rotation }) {
|
|
718
|
+
this._basicOutpoint({ x, y, size, rotation });
|
|
719
|
+
}
|
|
720
|
+
_drawInpoint({ x, y, size, rotation }) {
|
|
721
|
+
this._basicInpoint({ x, y, size, rotation });
|
|
722
|
+
}
|
|
352
723
|
}
|
|
353
724
|
|
|
354
725
|
class QRDot {
|
|
@@ -364,6 +735,9 @@ class QRDot {
|
|
|
364
735
|
case DotType.dots:
|
|
365
736
|
drawFunction = this._drawDot;
|
|
366
737
|
break;
|
|
738
|
+
case DotType.randomDots:
|
|
739
|
+
drawFunction = this._drawRandomDot;
|
|
740
|
+
break;
|
|
367
741
|
case DotType.classy:
|
|
368
742
|
drawFunction = this._drawClassy;
|
|
369
743
|
break;
|
|
@@ -373,9 +747,21 @@ class QRDot {
|
|
|
373
747
|
case DotType.rounded:
|
|
374
748
|
drawFunction = this._drawRounded;
|
|
375
749
|
break;
|
|
750
|
+
case DotType.verticalLines:
|
|
751
|
+
drawFunction = this._drawVerticalLines;
|
|
752
|
+
break;
|
|
753
|
+
case DotType.horizontalLines:
|
|
754
|
+
drawFunction = this._drawHorizontalLines;
|
|
755
|
+
break;
|
|
376
756
|
case DotType.extraRounded:
|
|
377
757
|
drawFunction = this._drawExtraRounded;
|
|
378
758
|
break;
|
|
759
|
+
case DotType.diamond:
|
|
760
|
+
drawFunction = this._drawDiamond;
|
|
761
|
+
break;
|
|
762
|
+
case DotType.smallSquare:
|
|
763
|
+
drawFunction = this._drawSmallSquare;
|
|
764
|
+
break;
|
|
379
765
|
case DotType.square:
|
|
380
766
|
default:
|
|
381
767
|
drawFunction = this._drawSquare;
|
|
@@ -479,9 +865,23 @@ class QRDot {
|
|
|
479
865
|
_drawDot({ x, y, size }) {
|
|
480
866
|
this._basicDot({ x, y, size, rotation: 0 });
|
|
481
867
|
}
|
|
868
|
+
_drawRandomDot({ x, y, size }) {
|
|
869
|
+
const randomFactor = Math.random() * (1 - 0.75) + 0.75;
|
|
870
|
+
this._basicDot({ x, y, size: size * randomFactor, rotation: 0 });
|
|
871
|
+
}
|
|
482
872
|
_drawSquare({ x, y, size }) {
|
|
483
873
|
this._basicSquare({ x, y, size, rotation: 0 });
|
|
484
874
|
}
|
|
875
|
+
_drawSmallSquare({ x, y, size }) {
|
|
876
|
+
const originalSize = size;
|
|
877
|
+
size = originalSize * 0.7;
|
|
878
|
+
x = x + originalSize * 0.15;
|
|
879
|
+
y = y + originalSize * 0.15;
|
|
880
|
+
this._basicSquare({ x, y, size, rotation: 0 });
|
|
881
|
+
}
|
|
882
|
+
_drawDiamond({ x, y, size }) {
|
|
883
|
+
this._basicSquare({ x, y, size, rotation: Math.PI / 4 });
|
|
884
|
+
}
|
|
485
885
|
_drawRounded({ x, y, size, getNeighbor }) {
|
|
486
886
|
const leftNeighbor = getNeighbor ? +getNeighbor(-1, 0) : 0;
|
|
487
887
|
const rightNeighbor = getNeighbor ? +getNeighbor(1, 0) : 0;
|
|
@@ -525,6 +925,60 @@ class QRDot {
|
|
|
525
925
|
return;
|
|
526
926
|
}
|
|
527
927
|
}
|
|
928
|
+
_drawVerticalLines({ x, y, size, getNeighbor }) {
|
|
929
|
+
const leftNeighbor = getNeighbor ? +getNeighbor(-1, 0) : 0;
|
|
930
|
+
const rightNeighbor = getNeighbor ? +getNeighbor(1, 0) : 0;
|
|
931
|
+
const topNeighbor = getNeighbor ? +getNeighbor(0, -1) : 0;
|
|
932
|
+
const bottomNeighbor = getNeighbor ? +getNeighbor(0, 1) : 0;
|
|
933
|
+
const neighborsCount = leftNeighbor + rightNeighbor + topNeighbor + bottomNeighbor;
|
|
934
|
+
if (neighborsCount === 0 ||
|
|
935
|
+
(leftNeighbor && !(topNeighbor || bottomNeighbor)) ||
|
|
936
|
+
(rightNeighbor && !(topNeighbor || bottomNeighbor))) {
|
|
937
|
+
this._basicDot({ x, y, size, rotation: 0 });
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
if (topNeighbor && bottomNeighbor) {
|
|
941
|
+
this._basicSquare({ x, y, size, rotation: 0 });
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
if (topNeighbor && !bottomNeighbor) {
|
|
945
|
+
const rotation = Math.PI / 2;
|
|
946
|
+
this._basicSideRounded({ x, y, size, rotation });
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
if (bottomNeighbor && !topNeighbor) {
|
|
950
|
+
const rotation = -Math.PI / 2;
|
|
951
|
+
this._basicSideRounded({ x, y, size, rotation });
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
_drawHorizontalLines({ x, y, size, getNeighbor }) {
|
|
956
|
+
const leftNeighbor = getNeighbor ? +getNeighbor(-1, 0) : 0;
|
|
957
|
+
const rightNeighbor = getNeighbor ? +getNeighbor(1, 0) : 0;
|
|
958
|
+
const topNeighbor = getNeighbor ? +getNeighbor(0, -1) : 0;
|
|
959
|
+
const bottomNeighbor = getNeighbor ? +getNeighbor(0, 1) : 0;
|
|
960
|
+
const neighborsCount = leftNeighbor + rightNeighbor + topNeighbor + bottomNeighbor;
|
|
961
|
+
if (neighborsCount === 0 ||
|
|
962
|
+
(topNeighbor && !(leftNeighbor || rightNeighbor)) ||
|
|
963
|
+
(bottomNeighbor && !(leftNeighbor || rightNeighbor))) {
|
|
964
|
+
this._basicDot({ x, y, size, rotation: 0 });
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
if (leftNeighbor && rightNeighbor) {
|
|
968
|
+
this._basicSquare({ x, y, size, rotation: 0 });
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
if (leftNeighbor && !rightNeighbor) {
|
|
972
|
+
const rotation = 0;
|
|
973
|
+
this._basicSideRounded({ x, y, size, rotation });
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
976
|
+
if (rightNeighbor && !leftNeighbor) {
|
|
977
|
+
const rotation = Math.PI;
|
|
978
|
+
this._basicSideRounded({ x, y, size, rotation });
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
528
982
|
_drawExtraRounded({ x, y, size, getNeighbor }) {
|
|
529
983
|
const leftNeighbor = getNeighbor ? +getNeighbor(-1, 0) : 0;
|
|
530
984
|
const rightNeighbor = getNeighbor ? +getNeighbor(1, 0) : 0;
|