I want to create a canvas object in memory, and not require a HTML <canvas> tag. Is this possible?
With this code:
var canvas = new Canvas();
var ctx = canvas.getContext('2d');
I get this error message: Uncaught ReferenceError: Canvas is not defined
You should be able to create the element with JavaScript:
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
Use document.createElement("canvas") instead. There is no Canvas constructor for canvases, as you know it from Image for images or Option for options - those are the sole exceptions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With