new Canvas(w, h) returns a <canvas> element with the export methods
assigned onto it, so the result is a DOM node: it can be appended to the
document, and instanceof HTMLCanvasElement holds where
instanceof Canvas does not.
Unlike the Node constructor it takes no options object: pixel format,
color space and renderer are the browser's to choose. Both dimensions are
assigned onto the element as given, so new Canvas() is 0 x 0 rather than
the 300 x 150 an empty <canvas> would be -- pass a size, or set width
and height afterwards.
The browser
Canvasconstructor.new Canvas(w, h)returns a<canvas>element with the export methods assigned onto it, so the result is a DOM node: it can be appended to the document, andinstanceof HTMLCanvasElementholds whereinstanceof Canvasdoes not.Unlike the Node constructor it takes no options object: pixel format, color space and renderer are the browser's to choose. Both dimensions are assigned onto the element as given, so
new Canvas()is 0 x 0 rather than the 300 x 150 an empty<canvas>would be -- pass a size, or setwidthandheightafterwards.