Skip to content

Instantly share code, notes, and snippets.

@IGI-111
Created December 5, 2016 13:43
Show Gist options
  • Save IGI-111/872ef205a7b0c5d93ab5046e858692c9 to your computer and use it in GitHub Desktop.
Save IGI-111/872ef205a7b0c5d93ab5046e858692c9 to your computer and use it in GitHub Desktop.
Make a QR code with braille characters.
const qr = require('qrcode');
const Canvas = require('drawille');
qr.drawBitArray(process.argv[2], (err,bits,width) => {
if(err){
console.error(err);
return;
}
let height = Math.ceil(bits.length / width);
let canvas = new Canvas(width, height);
for (let x = 0; x < width; ++x) {
for (let y = 0; y < height; ++y) {
if(bits[y * width + x]){
canvas.set(x, y);
}
}
}
process.stdout.write(canvas.frame());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment