UNPKG

@thi.ng/pixel

Version:

Typedarray integer & float pixel buffers w/ customizable formats, blitting, drawing, convolution

23 lines 1.13 kB
import { type Canvas2DOpts } from "@thi.ng/canvas"; import type { OffscreenRawPixelBuffer, RawPixelBuffer } from "./api.js"; import type { FloatBuffer } from "./float.js"; import type { IntBuffer } from "./int.js"; /** * Accepts either an existing canvas or creates a new one of given size. * Returns object of canvas, 2d context, img data and wrapped img data * as u32 ABGR pixel array. */ export declare function canvasPixels(canvas: HTMLCanvasElement): RawPixelBuffer; export declare function canvasPixels(canvas: OffscreenCanvas): OffscreenRawPixelBuffer; export declare function canvasPixels(width: number, height?: number, parent?: HTMLElement | null, opts?: Partial<Canvas2DOpts>): RawPixelBuffer; /** * Creates an HTML canvas from the given pixel buffer and returns it. The canvas * can be attached/appended to a given `parent` element and configured via given * `opts`. * * @param buf * @param parent * @param opts */ export declare const canvasFromPixelBuffer: (buf: IntBuffer | FloatBuffer, parent?: HTMLElement | null, opts?: Partial<Canvas2DOpts>) => HTMLCanvasElement; //# sourceMappingURL=canvas.d.ts.map