Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/evt/lib/index.ts>dom.HTMLCanvasElement

💧EventEmitter's typesafe replacement
Go to Latest
interface dom.HTMLCanvasElement
implements HTMLElement
import { type dom } from "https://deno.land/x/evt@v2.4.22/lib/index.ts";
const { HTMLCanvasElement } = dom;

Provides properties and methods for manipulating the layout and presentation of elements. The HTMLCanvasElement interface also inherits the properties and methods of the HTMLElement interface.

Properties

height: number

Gets or sets the height of a canvas element on a document.

width: number

Gets or sets the width of a canvas element on a document.

Methods

getContext(contextId: "2d", options?: CanvasRenderingContext2DSettings): CanvasRenderingContext2D | null

Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas.

getContext(contextId: "bitmaprenderer", options?: ImageBitmapRenderingContextSettings): ImageBitmapRenderingContext | null
getContext(contextId: "webgl", options?: WebGLContextAttributes): WebGLRenderingContext | null
getContext(contextId: "webgl2", options?: WebGLContextAttributes): WebGL2RenderingContext | null
getContext(contextId: string, options?: any): RenderingContext | null
toBlob(
callback: BlobCallback,
type?: string,
quality?: any,
): void
toDataURL(type?: string, quality?: any): string

Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element.

transferControlToOffscreen(): OffscreenCanvas
addEventListener<K extends keyof HTMLElementEventMap>(
type: K,
listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void
addEventListener(
type: string,
options?: boolean | AddEventListenerOptions,
): void
removeEventListener<K extends keyof HTMLElementEventMap>(
type: K,
listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void
removeEventListener(
type: string,
options?: boolean | EventListenerOptions,
): void