import { Canvas } from "./canvas.js"; import type { Canvas2DOptions } from "./canvas2d.js"; /** * An offscreen canvas. * * This isn't created from a DOM node, but from an existing {@linkcode !OffscreenCanvas}. */ export declare class Canvas2DHeadless extends Canvas { #private; /** * Retrieves the rendering context of the canvas. * @returns The rendering context of the canvas. */ get context(): OffscreenCanvasRenderingContext2D; /** * Our back buffer. */ buffer: Uint8ClampedArray; /** * The configuration that was used for this canvas. */ readonly options: Readonly>; /** * Constructs a new {@linkcode Canvas2DHeadless}. * @param canvas - The offscreen canvas we're drawing to. * @param context - The rendering context to use for the canvas. * @param options - The configuration for this canvas. */ constructor(canvas: OffscreenCanvas, context: OffscreenCanvasRenderingContext2D, options?: Partial); /** * Recreate internal buffers in reaction to a change in our target {@linkcode !OffscreenCanvas}. */ refreshCanvasNode(): void; /** * Draw FPS information onto the canvas. * @param frameTimes - Durations of previous frame draws. * @param frameTime - The duration of the previous frame draw. * @param timeDelta - The time elapsed since the last frame. */ renderFpsInfo(frameTimes: Array, frameTime: number, timeDelta: number): void; /** * Draws the back buffer onto the canvas. */ update(): void; /** * Draws the offscreen canvas into the DOM canvas. */ render(): void; /** * Draws a slightly transparent, black rectangle over the canvas, * and then reads the result back into the buffer. * @param color - The color to fade the buffer with. The alpha component of * the color defines how strong the fade is. `0` is not at all, `255` makes * it instantly black. */ fade(color?: number): void; /** * Reads the front buffer back into the back buffer. */ bufferReadBack(): void; /** * Returns the color of a pixel in the back buffer. * @param x - The X coordinate to retrieve. * @param y - The X coordinate to retrieve. * @returns The color of the pixel at the given local. */ getPixel32(x: number, y: number): number; /** * Colors a pixel in the back buffer. * @param x - The X coordinate to color. * @param y - The Y coordinate to color. * @param color - The color to place at the coordinate. */ setPixel32(x: number, y: number, color: number): void; /** * Fills the entire back buffer with the given color. * @param color - The color to fill the back buffer with. */ clearWith(color: number): void; /** * Fills the entire back buffer with the given color. * @param color - The color to fill the back buffer with. */ blendWith(color: number): void; }