import type { Canvas } from "./canvas.js"; /** * The amount of milliseconds your can spend in a frame, if you want to * reach a frame rate of 60 FPS. */ export declare const MS_PER_FRAME_60FPS: number; /** * The signature of a function that is called to draw a frame. */ export type RenderLoopCallback = (delta: number, timestamp: number) => unknown; /** * Configuration for a {@linkcode RenderLoop}, */ export interface RenderLoopOptions { /** * Should the current frames per second be rendered onto the canvas * each frame? */ drawFps: boolean; /** * Should the buffer be cleared or faded to black before each frame? */ onRefresh: "clear"; } /** * Conveniently provides a way to have a render loop called at * a constant frame rate. */ export declare class RenderLoop { #private; /** * The {@linkcode Canvas} we're rendering to. */ readonly canvas: Canvas; /** * A function that we call when a new frame should be drawn. */ readonly renderLoop: RenderLoopCallback; /** * The configuration that was used for this render loop. */ readonly options: Readonly>; /** * The time at which we drew the last frame to the offscreen buffer. */ private previousTimestampDraw; /** * The ID of our {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame requestAnimationFrame} request. */ private frameRequestId; /** * The ID of our {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/setTimeout setTimeout}-based * offscreen rendering loop. */ private drawTimeout; /** * Retrieves the amount of frames drawn to the DOM throughout the loops lifetime. * @returns The frame count. */ get frameCounter(): number; /** * Constructs a new {@linkcode RenderLoop}. * @param renderLoop - The function to call when a new frame should be drawn. * @param canvas - The canvas we're rendering to. * @param options - The configuration for thie {@linkcode RenderLoop}. */ constructor(renderLoop: RenderLoopCallback, canvas: Canvas, options?: Partial); /** * Stop the render loop. */ block(): void; /** * Start the render loop. */ unblock(): void; }