Skip to content

Commit 2b5456c

Browse files
committed
Fixes #3730: QR code quiet space
1 parent 292bea1 commit 2b5456c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/shared/qrcode/component.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,20 @@ class QRCodeComponent extends CustomElement {
3131

3232
render() {
3333
const nCount = this.#qr_code.getModuleCount();
34+
const quietZone = 4;
35+
const totalCount = nCount + 2 * quietZone;
3436
const rects = [];
3537

3638
for (let row = 0; row < nCount; row++) {
3739
for (let col = 0; col < nCount; col++) {
3840
if (this.#qr_code.isDark(row, col)) {
39-
rects.push(svg`<use x="${row}" y="${col}" href="#template"></use>`);
41+
rects.push(svg`<use x="${row + quietZone}" y="${col + quietZone}" href="#template"></use>`);
4042
}
4143
}
4244
}
4345

4446
return svg`
45-
<svg viewBox="0 0 ${nCount} ${nCount}" width="${this.width}" height="${this.height}" fill="${this.colorLight}">
47+
<svg viewBox="0 0 ${totalCount} ${totalCount}" width="${this.width}" height="${this.height}" fill="${this.colorLight}">
4648
<rect fill="${this.colorLight}" width="100%" height="100%"></rect>
4749
<rect fill="${this.colorDark}" width="1" height="1" id="template"></rect>
4850
${rects}

0 commit comments

Comments
 (0)