elexis/lib/node/$Canvas.ts
defaultkavy b3f28dbf86 v0.0.7
change: Router.open(), .replace() .back(), .events change to static
add: $.open(), $.replace(), $.back()
add: $.html() convert html string to $Element
update: $State support output format
update: $Util.from() convert children node to $Element
change: $Node.parent change to getter
change: using $StateArgument<T>
new: $SVGElement, $HTMLElement
new: $AsyncNode
add: $Image.load()
2024-04-23 18:18:43 +08:00

29 lines
1.6 KiB
TypeScript

import { $Container, $ContainerOptions } from "./$Container";
export interface $CanvasOptions extends $ContainerOptions {}
export class $Canvas extends $Container<HTMLCanvasElement> {
constructor(options?: $CanvasOptions) {
super('canvas', options);
}
height(): number;
height(height?: number): this;
height(height?: number) { return $.fluent(this, arguments, () => this.dom.height, () => { $.set(this.dom, 'height', height)}) }
width(): number;
width(width?: number): this;
width(width?: number) { return $.fluent(this, arguments, () => this.dom.width, () => { $.set(this.dom, 'width', width)}) }
captureStream(frameRequestRate?: number) { return this.dom.captureStream(frameRequestRate) }
getContext(contextId: "2d", options?: CanvasRenderingContext2DSettings): CanvasRenderingContext2D | null;
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 { return this.dom.getContext(contextId); }
toBlob(callback: BlobCallback, type?: string, quality?: any) { this.dom.toBlob(callback, type, quality); return this;}
toDataURL(type?: string, quality?: any) { return this.dom.toDataURL(type, quality) }
transferControlToOffscreen() { return this.dom.transferControlToOffscreen() }
}