servez 1.13.1 → 1.13.2
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/bin/servez +28 -4
- package/package.json +1 -1
package/bin/servez
CHANGED
|
@@ -20,17 +20,41 @@ const log = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
function genQRCode(s) {
|
|
23
|
+
const blockChars = [
|
|
24
|
+
' ', // 0
|
|
25
|
+
'▘', // 1
|
|
26
|
+
'▝', // 2
|
|
27
|
+
'▀', // 3
|
|
28
|
+
'▖', // 4
|
|
29
|
+
'▌', // 5
|
|
30
|
+
'▞', // 6
|
|
31
|
+
'▛', // 7
|
|
32
|
+
'▗', // 8
|
|
33
|
+
'▚', // 9
|
|
34
|
+
'▐', // 10
|
|
35
|
+
'▜', // 11
|
|
36
|
+
'▄', // 12
|
|
37
|
+
'▙', // 13
|
|
38
|
+
'▟', // 14
|
|
39
|
+
'█', // 15
|
|
40
|
+
];
|
|
41
|
+
|
|
23
42
|
const qr = QrCode.encodeText(s, Ecc.MEDIUM);
|
|
43
|
+
const size = ((qr.size + 1) / 2 | 0) * 2 + 2;
|
|
24
44
|
|
|
25
45
|
const lines = [];
|
|
26
|
-
for (let y =
|
|
46
|
+
for (let y = -2; y < size; y += 2) {
|
|
27
47
|
const line = [];
|
|
28
|
-
for (let x =
|
|
29
|
-
|
|
48
|
+
for (let x = -2; x < size; x += 1) {
|
|
49
|
+
const code = (qr.getModule(x + 0, y + 0) ? 1 : 0) |
|
|
50
|
+
(qr.getModule(x + 0, y + 0) ? 2 : 0) |
|
|
51
|
+
(qr.getModule(x + 0, y + 1) ? 4 : 0) |
|
|
52
|
+
(qr.getModule(x + 0, y + 1) ? 8 : 0) ;
|
|
53
|
+
line.push(blockChars[code]);
|
|
30
54
|
}
|
|
31
55
|
lines.push(line.join(''));
|
|
32
56
|
}
|
|
33
|
-
return lines.join('\n');
|
|
57
|
+
return c.bgWhite(c.black(lines.join('\n')));
|
|
34
58
|
}
|
|
35
59
|
|
|
36
60
|
const optionSpec = {
|