Closed piratov closed 7 months ago
https://github.com/nayuki/QR-Code-generator/releases
<script src="/qrcodegen-v1.8.0-es6.min.js"></script>
export function drawNayukiQrCanvas(qr, scale, border, lightColor, darkColor, canvas) {
if (scale <= 0) scale = 1;
if (border < 0) border = 0;
const width = (qr.size + border * 2) * scale;
canvas.width = width;
canvas.height = width;
let ctx = canvas.getContext("2d");
for (let y = -border; y < qr.size + border; y++) {
for (let x = -border; x < qr.size + border; x++) {
ctx.fillStyle = qr.getModule(x, y) ? darkColor : lightColor;
ctx.fillRect((x + border) * scale, (y + border) * scale, scale, scale);
}
}
}
const text = "Hello, world!";
const errCorLvl = qrcodegen.QrCode.Ecc.MEDIUM;
const qr = qrcodegen.QrCode.encodeText(text, errCorLvl);
drawNayukiQrCanvas(qr, 12, 1, "#ffffff", "#000000", qrcodeRef);
1 Add possibility for groups and channels shares QRCode 2 Share QRCode user contacts (vCard)
thx!