HTMLCanvasElement Class | |
---|---|
Inherits | Description |
HTMLElement | This represents any HTML element. |
Element | This represents any kind of element in a document, including types like MathML or SVG elements. |
Node | This represent every kind of DOM node, including a document. |
EventTarget | This represents a broader group of objects that can receive event notices. |
Properties | Description |
height | This defines the height of the canvas element in pixels. |
width | This defines the width of the canvas element in pixels. |
Methods | Description |
MediaStream captureStream(fps = auto) | This function takes a parameter that specifies the number of frames that are captured per second. If nothing is passed to the function, a frame is captured each time the canvas changes. If 0 is passed in a frame will captured only when requestFrame() is called on the returned object. |
various getContext(conType) various getContext(conType, conAttr) |
This function gets a context for drawing onto the canvas element. The first parameter, conType, is string that defines the type of context and it has one of the following values: "2d", "webgl" (originally "experimental-webgl"), "webgl12", "webgpu", or "bitmaprenderer". The second paramter, conAttr, is an object that contains a set of values to that define the nature of the context with the following members:
|
toBlob(callback) toBlob(callback, type) toBlob(callback, type, quality) |
This create a blob from the canvas image data and passes it into the callback. The parameter, callback, is a function that takes the Blob object as its only argument. The type paramter is a string that specifies the type of the blob and its default value is "image/png". The quality parameter is a number from 0 to 1 that indicates the quality for lossy formats, like "image/jpeg" or "image/webp". |
string toDataURL() string toDataURL(type) string toDataURL(type, quality) |
This function returns a URL that contains a base64 specification of the image of the canvas. The type paramter is a string that specifies the type of the blob and its default value is "image/png". The quality parameter is a number from 0 to 1 that indicates the quality for lossy formats, like "image/jpeg" or "image/webp". |
transferControlToOffscreen() | This tranfers control to an offscreen canvas. Operations may be specified on a separate worker thread. |
Events | Description |
webglcontextcreationerror | The context can not be created. |
webglcontextlost | The current context loses its drawing buffer. |
webglcontextrestored | The context is restored, but previously created resources are no longer valid. |
© 20072025 XoaX.net LLC. All rights reserved.