Skip to content

HTMLCanvasElement

Generated from idl/canvas.webidl when the site was built at 7aa23e2.

HTMLCanvasElement is an interface in idl/canvas.webidl, inheriting HTMLElement, exposed in Window. What it does is on MDN; this page says what niso has of it.

The web features its members belong to, each with its Baseline status on the web and how much of the feature’s WPT suite passes in niso (see Web platform support).

Feature On the web In niso Members
<canvas> Widely available Partial 68% 143 of 208 subtests pass 6
constructor
[HTMLConstructor] constructor();
attribute
attribute unsigned long width;
int32_t niso_html_canvas_element_get_width(niso_dom* dom, niso_handle self, uint32_t* out);
int32_t niso_html_canvas_element_set_width(niso_dom* dom, niso_handle self, uint32_t value);
attribute
attribute unsigned long height;
int32_t niso_html_canvas_element_get_height(niso_dom* dom, niso_handle self, uint32_t* out);
int32_t niso_html_canvas_element_set_height(niso_dom* dom, niso_handle self, uint32_t value);
operation
[NisoGlue] RenderingContext? getContext(DOMString contextId, optional any options = null);
operation
[NisoGlue] USVString toDataURL(optional DOMString type = "image/png", optional any quality);
operation
[NisoGlue] undefined toBlob(BlobCallback callback, optional DOMString type = "image/png", optional any quality);
operation not in JS
[NisoInternal] CanvasRenderingContext2D context2d(boolean alpha, boolean willReadFrequently);
int32_t niso_html_canvas_element_context2d(niso_dom* dom, niso_handle self, bool alpha, bool will_read_frequently, niso_handle* out);

The 2D context, made on the first call with its settings.

operation not in JS
[NisoInternal] ArrayBuffer encodePng();
int32_t niso_html_canvas_element_encode_png(niso_dom* dom, niso_handle self, niso_bytes* out);

The bitmap as a PNG file; empty without a bitmap.

Members the web has, by the BCD keys web-features 3.45.0 lists, that idl/ doesn’t declare. The list is partial: web-features lists only the keys it maps to a feature.

  • captureElementImage (HTML-in-canvas)
  • captureStream (captureStream() for <canvas>)
  • clearElementGeometry (HTML-in-canvas)
  • content (HTML-in-canvas)
  • contextlost event (contextlost and contextrestored)
  • contextrestored event (contextlost and contextrestored)
  • elementgeometryupdate event (HTML-in-canvas)
  • getElementImageDefaultSize (HTML-in-canvas)
  • getElementTransform (HTML-in-canvas)
  • paint event (HTML-in-canvas)
  • requestPaint (HTML-in-canvas)
  • transferControlToOffscreen (Offscreen canvas)
  • updateElementGeometry (HTML-in-canvas)
  • webglcontextcreationerror event (WebGL)
  • webglcontextlost event (WebGL)
  • webglcontextrestored event (WebGL)