OffscreenCanvas Class | |
---|---|
Inherits | Description |
EventTarget | This represents a broader group of objects that can receive event notices. |
Constructors | Description |
OffscreenCanvas(w, h) | This constructs an OffscreenCanvas object with the width and height given by w and h. |
Properties | Description |
height | This defines the height of the OffscreenCanvas in pixels. |
width | This defines the width of the OffscreenCanvas in pixels. |
Methods | Description |
Promise convertToBlob() Promise convertToBlob(opt) | The returns a Blob object in the image in the Canvas in the form of a Promise. The opt paramter can be a string that indicates an image format, such as "image/png", or a number between 0 and 1 to indicate the quality of the created image when performing a conversion to lossy compression. |
Object getContext(type, attrib) | This gets a context for drawing to the OffscreenCanvas, which may be of the type OffscreenCanvasRenderingContext2D, WebGLRenderingContext, WebGL2RenderingContext, or ImageBitmapRenderingContext. The type is a string that describes the type of context and it can have one of these values: "2d", "webgl", "webgl2", or "bitmaprenderer". The attrib paramter is an object with properties corresponding to the context type. For example, we might have { alpha: .5} for a "2d" context or {alpha: .75, depth: true, stencil: false, antialias: true, premultipliedAlpha: false, preserveDrawingBuffer: true, failIfMajorPerformanceCaveat: true} for a "webgl" context. |
ImageBitmap transferToImageBitmap() | This creates an ImageBitmap of the most recently rendered image. To preserve resources, this ImageBitmap should be closed() or consumed by passing it to a transferFromImageBitmap() method of an ImageBitmapRenderingContext. |
© 20072025 XoaX.net LLC. All rights reserved.