Created
May 6, 2025 19:03
-
-
Save dskvr/b9e3bbd6ad2d4150b1d31e14d00a51b7 to your computer and use it in GitHub Desktop.
for usage with @libs/qrcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _renderQrArrayWithQuietZone( | |
qrArray: boolean[][] | undefined, | |
borderSize: number, | |
lightCharPair = "\u2588\u2588", | |
darkCharPair = " " | |
): void { | |
if (!qrArray || qrArray.length === 0) { | |
log.warn("QR array is empty, cannot render."); | |
return; | |
} | |
const qrWidth = qrArray[0].length; | |
const totalWidthModules = qrWidth + 2 * borderSize; | |
for (let i = 0; i < borderSize; i++) { | |
console.log(lightCharPair.repeat(totalWidthModules)); | |
} | |
for (const row of qrArray) { | |
let line = ""; | |
line += lightCharPair.repeat(borderSize); | |
for (const cell of row) { | |
line += cell ? darkCharPair : lightCharPair; | |
} | |
line += lightCharPair.repeat(borderSize); | |
console.log(line); | |
} | |
for (let i = 0; i < borderSize; i++) { | |
console.log(lightCharPair.repeat(totalWidthModules)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment