neocotic / qrious

Pure JavaScript library for QR code generation using canvas
https://neocotic.com/qrious
Other
1.55k stars 215 forks source link

WebGL support #70

Closed esteban-filardi closed 7 years ago

esteban-filardi commented 7 years ago

Hi,

I'm trying to use this with PIXI.js for a game. PIXI.js uses webGl whenever available.The canvas is first created by PIXI. It seems this library fails if the canvas is using webgl.

Can anyone suggest me a solution using this library?

neocotic commented 7 years ago

@esteban-filardi I'm not familiar with PixiJS at all really but QRious is designed to generate the QR code and write it to the canvas provided (or create one where omitted). It is not designed to write to part of a canvas or to be embedded within a game as such as this would make the API more much complicated, more so than needed for intended usage.

Are you no able to overlay the QR canvas/image on top? I know this sounds hacky, but thought I'd check.

Apparently, PixiJS supports loading images from data URLs, so you might want to try the following:

var qr = new QRious({ value: 'Hello, World!' })
var qrTexture = PIXI.Texture.fromImage(qr.toDataURL())
esteban-filardi commented 7 years ago

I was able to make it work with the snippet of code you've sent. Thanks !