@liquid-js/qr-code-styling 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/figures/dot-elements.d.ts +1 -0
- package/lib/qr-code-styling-node.js +35 -5
- 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/tools/resize.d.ts +41 -0
- package/lib/utils/options.d.ts +2 -1
- package/package.json +2 -2
|
@@ -22,4 +22,5 @@ export declare const DotElements: {
|
|
|
22
22
|
innerRadius?: number | undefined;
|
|
23
23
|
}) => SVGElement;
|
|
24
24
|
weave: (args: BasicFigureDrawArgs) => SVGElement;
|
|
25
|
+
blob: (args: BasicFigureDrawArgs, corners: Record<"tl" | "tr" | "bl" | "br", "round" | "out" | "square">) => SVGElement;
|
|
25
26
|
};
|
|
@@ -51,7 +51,8 @@ function sanitizeGradient(gradient) {
|
|
|
51
51
|
DotType.diamond = "diamond", DotType.wave = "wave", DotType.heart = "heart", DotType.star = "star",
|
|
52
52
|
DotType.weave = "weave", DotType.pentagon = "pentagon", DotType.hexagon = "hexagon",
|
|
53
53
|
DotType.zebraHorizontal = "zebra-horizontal", DotType.zebraVertical = "zebra-vertical",
|
|
54
|
-
DotType.blocksHorizontal = "blocks-horizontal", DotType.blocksVertical = "blocks-vertical"
|
|
54
|
+
DotType.blocksHorizontal = "blocks-horizontal", DotType.blocksVertical = "blocks-vertical",
|
|
55
|
+
DotType.blobs = "blobs";
|
|
55
56
|
}(DotType || (DotType = {})), function(CornerDotType) {
|
|
56
57
|
CornerDotType.dot = "dot", CornerDotType.square = "square", CornerDotType.heart = "heart",
|
|
57
58
|
CornerDotType.extraRounded = "extra-rounded", CornerDotType.classy = "classy", CornerDotType.inpoint = "inpoint",
|
|
@@ -227,6 +228,21 @@ let DotElements = {
|
|
|
227
228
|
const {size, x, y, document} = args, thickness = .6 * size, notch = (size - thickness) / 2, element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
228
229
|
return element.setAttribute("d", svgPath`M ${x + notch} ${y} l ${thickness} 0 l 0 ${notch} l ${notch} 0 l 0 ${thickness} l ${-notch} 0 l 0 ${notch} l ${-thickness} 0 l 0 ${-notch} l ${-notch} 0 l 0 ${-thickness} l ${notch} 0 z`),
|
|
229
230
|
element;
|
|
231
|
+
},
|
|
232
|
+
blob: (args, corners) => {
|
|
233
|
+
const {size, x, y, document} = args, dotSize = size / 7, element = document.createElementNS("http://www.w3.org/2000/svg", "path"), parts = [ svgPath`M ${x} ${y + 2.5 * dotSize}` ];
|
|
234
|
+
let l = 2 * dotSize;
|
|
235
|
+
return "round" == corners.bl ? (parts.push(svgPath`v ${l} a ${2.5 * dotSize} ${2.5 * dotSize} 0 0 0 ${2.5 * dotSize} ${2.5 * dotSize}`),
|
|
236
|
+
l = 2 * dotSize) : "out" == corners.bl ? (parts.push(svgPath`v ${5 * dotSize + l} a ${2.5 * dotSize} ${2.5 * dotSize} 0 0 1 ${2.5 * dotSize} ${-2.5 * dotSize}`),
|
|
237
|
+
l = 2 * dotSize) : (parts.push(svgPath`v ${2.5 * dotSize + l}`), l = 4.5 * dotSize),
|
|
238
|
+
"round" == corners.br ? (parts.push(svgPath`h ${l} a ${2.5 * dotSize} ${2.5 * dotSize} 0 0 0 ${2.5 * dotSize} ${-2.5 * dotSize}`),
|
|
239
|
+
l = -2 * dotSize) : "out" == corners.br ? (parts.push(svgPath`h ${5 * dotSize + l} a ${2.5 * dotSize} ${2.5 * dotSize} 0 0 1 ${-2.5 * dotSize} ${-2.5 * dotSize}`),
|
|
240
|
+
l = -2 * dotSize) : (parts.push(svgPath`h ${2.5 * dotSize + l}`), l = -4.5 * dotSize),
|
|
241
|
+
"round" == corners.tr ? (parts.push(svgPath`v ${l} a ${2.5 * dotSize} ${2.5 * dotSize} 0 0 0 ${-2.5 * dotSize} ${-2.5 * dotSize}`),
|
|
242
|
+
l = -2 * dotSize) : "out" == corners.tr ? (parts.push(svgPath`v ${-5 * dotSize + l} a ${2.5 * dotSize} ${2.5 * dotSize} 0 0 1 ${-2.5 * dotSize} ${2.5 * dotSize}`),
|
|
243
|
+
l = -2 * dotSize) : (parts.push(svgPath`v ${-2.5 * dotSize + l}`), l = -4.5 * dotSize),
|
|
244
|
+
"round" == corners.tl ? parts.push(svgPath`h ${l} a ${2.5 * dotSize} ${2.5 * dotSize} 0 0 0 ${-2.5 * dotSize} ${2.5 * dotSize}`) : "out" == corners.tl ? parts.push(svgPath`h ${-5 * dotSize + l} a ${2.5 * dotSize} ${2.5 * dotSize} 0 0 1 ${2.5 * dotSize} ${2.5 * dotSize}`) : parts.push(svgPath`h ${-2.5 * dotSize + l}`),
|
|
245
|
+
element.setAttribute("d", parts.join(" ") + " z"), element;
|
|
230
246
|
}
|
|
231
247
|
}, qrCornerDotFigures = {
|
|
232
248
|
[CornerDotType.dot]: args => rotateFigure({
|
|
@@ -313,7 +329,7 @@ let SquareElements = {
|
|
|
313
329
|
[ element, fill ];
|
|
314
330
|
},
|
|
315
331
|
centerCircle: args => {
|
|
316
|
-
const {x, y, size} = args, circleRadius = size / 2.5, cx = x + size / 2, cy = y + size / 2, dotSize = size / 7, element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
332
|
+
const {x, y, size, document} = args, circleRadius = size / 2.5, cx = x + size / 2, cy = y + size / 2, dotSize = size / 7, element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
317
333
|
element.setAttribute("clip-rule", "evenodd"), element.setAttribute("d", svgPath`M ${x} ${y} h ${size} v ${size} h ${-size} z M ${cx - circleRadius} ${cy} a ${circleRadius} ${circleRadius} 0 1 0 ${2 * circleRadius} 0 a ${circleRadius} ${circleRadius} 0 1 0 ${2 * -circleRadius} 0 z`);
|
|
318
334
|
const fill = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
319
335
|
return fill.setAttribute("clip-rule", "evenodd"), fill.setAttribute("d", svgPath`M ${x - dotSize} ${y - dotSize} h ${size + 2 * dotSize} v ${size + 2 * dotSize} h ${-size - 2 * dotSize} z`),
|
|
@@ -580,7 +596,19 @@ let qrDotFigures = {
|
|
|
580
596
|
height
|
|
581
597
|
});
|
|
582
598
|
}
|
|
583
|
-
})
|
|
599
|
+
}),
|
|
600
|
+
[DotType.blobs]: ({getNeighbor, ...args}) => {
|
|
601
|
+
const tl = getNeighbor?.(-1, -1), t = getNeighbor?.(0, -1), tr = getNeighbor?.(1, -1), r = getNeighbor?.(1, 0), br = getNeighbor?.(1, 1), b = getNeighbor?.(0, 1), bl = getNeighbor?.(-1, 1), l = getNeighbor?.(-1, 0), corners = {
|
|
602
|
+
tl: "square",
|
|
603
|
+
tr: "square",
|
|
604
|
+
bl: "square",
|
|
605
|
+
br: "square"
|
|
606
|
+
};
|
|
607
|
+
return !l && tl && (corners.tl = "out"), !t && tr && (corners.tr = "out"), !r && br && (corners.br = "out"),
|
|
608
|
+
!b && bl && (corners.bl = "out"), l || tl || t || (corners.tl = "round"), t || tr || r || (corners.tr = "round"),
|
|
609
|
+
r || br || b || (corners.br = "round"), b || bl || l || (corners.bl = "round"),
|
|
610
|
+
DotElements.blob(args, corners);
|
|
611
|
+
}
|
|
584
612
|
};
|
|
585
613
|
|
|
586
614
|
function getQrDotFigure(type, plugins) {
|
|
@@ -1138,11 +1166,13 @@ let QRCodeStyling$1 = class {
|
|
|
1138
1166
|
}
|
|
1139
1167
|
};
|
|
1140
1168
|
|
|
1141
|
-
var FileExtension;
|
|
1169
|
+
var KernelType, FileExtension;
|
|
1142
1170
|
|
|
1143
1171
|
let browserUtils;
|
|
1144
1172
|
|
|
1145
|
-
!function(
|
|
1173
|
+
!function(KernelType) {
|
|
1174
|
+
KernelType.Lanczos = "lanczos", KernelType.Linear = "linear";
|
|
1175
|
+
}(KernelType || (KernelType = {})), KernelType.Lanczos, KernelType.Linear, function(FileExtension) {
|
|
1146
1176
|
FileExtension.svg = "svg", FileExtension.png = "png", FileExtension.jpeg = "jpeg",
|
|
1147
1177
|
FileExtension.webp = "webp";
|
|
1148
1178
|
}(FileExtension || (FileExtension = {}));
|