File tree 1 file changed +4
-26
lines changed
1 file changed +4
-26
lines changed Original file line number Diff line number Diff line change @@ -20,41 +20,19 @@ 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
24
const qr = QrCode . encodeText ( s , Ecc . MEDIUM ) ;
43
25
const size = ( ( qr . size + 1 ) / 2 | 0 ) * 2 + 2 ;
44
26
45
27
const lines = [ ] ;
46
- for ( let y = - 2 ; y < size ; y += 2 ) {
28
+ for ( let y = - 2 ; y < size ; ++ y ) {
47
29
const line = [ ] ;
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
+ for ( let x = - 2 ; x < size ; ++ x ) {
31
+ line . push ( c [ qr . getModule ( x , y ) ? 'bgBlack' : 'bgWhite' ] ( ' ' ) ) ;
54
32
}
55
33
lines . push ( line . join ( '' ) ) ;
56
34
}
57
- return c . bgWhite ( c . black ( lines . join ( '\n' ) ) ) ;
35
+ return lines . join ( '\n' ) ;
58
36
}
59
37
60
38
const optionSpec = {
You can’t perform that action at this time.
0 commit comments