Hey, I have added renderTo2dContext function which takes a context one would get by calling getContext('2d') on a canvas element and optional cellSize and renders the QR code onto the canvas.
I decided against adding x and y coordinate arguments as I expect people will, like me, want to use this to render to a canvas element prepared so that it is a perfect fit for the QR code. I can add it if you like.
I have also avoided updating the demo, as it didn't seem like showcasing rendering to canvas would add anything to it (it doesn't list API methods or anything). One thing to note, though, is that the qrcode.js file in the demo and the one directly in jsare different. I am not sure if you are aware of this. I didn't find any way through which the file in the demo was copied over from the main file or anything like that, so I left it alone, but I can fix that for you by replacing the demo file with the main file. Let me know if you want that.
Hey, I have added
renderTo2dContext
function which takes acontext
one would get by callinggetContext('2d')
on acanvas
element and optionalcellSize
and renders the QR code onto the canvas.I decided against adding
x
andy
coordinate arguments as I expect people will, like me, want to use this to render to acanvas
element prepared so that it is a perfect fit for the QR code. I can add it if you like.I have also avoided updating the demo, as it didn't seem like showcasing rendering to
canvas
would add anything to it (it doesn't list API methods or anything). One thing to note, though, is that theqrcode.js
file in the demo and the one directly injs
are different. I am not sure if you are aware of this. I didn't find any way through which the file in the demo was copied over from the main file or anything like that, so I left it alone, but I can fix that for you by replacing the demo file with the main file. Let me know if you want that.