barcode_qr
Generate QR Code
barcode_qr(
text,
[res]
)
Generate QR Code
Syntaxe
var cb = barcode_qr("https://richnou.ovh", res=QRHIGH);
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
text | yes | - | Text to use | |
res | - | - | Low (25x25) or High (29x29) - use constant QRLOW o QRHIGH |
Full example
var dark = "#111314";
var light = "#f5ecc2";
var margin = 50; // tout autour
var size = 20; // de chaque carré
var resolution = QRLOW ; // QRLOW ou QRHIGH
var canvasSize = margin*2 + size*resolution;
canvas(width=canvasSize, height=canvasSize, background=light);
var cb = barcode_qr("https://richnou.ovh", res=resolution);
stroke("transparent");
coord_translate(margin,margin);
var x = 0;
var y = 0;
for (var i = 0; i < length(cb); i++) {
var color = dark;
if (cb[i] == 0) {
color = light;
}
square(x=x * size, y=y * size, size=size, fill=color);
x += 1;
if (i % resolution == resolution - 1) {
x = 0;
y += 1;
}
}
save(whoami() + ".png");
