UNPKG

vevet

Version:

Vevet is a JavaScript library for creative development that simplifies crafting rich interactions like split text animations, carousels, marquees, preloading, and more.

62 lines 2.5 kB
import { Module, TModuleOnCallbacksProps } from '../../base/Module'; import { TRequiredProps } from '../../internal/requiredProps'; import { ICanvasCallbacksMap, ICanvasMutableProps, ICanvasStaticProps, TCanvasRender } from './types'; export * from './types'; /** * A class for managing an HTML5 Canvas element and its 2D context. * * [Documentation](https://vevetjs.com/docs/Canvas) * * @group Components */ export declare class Canvas<C extends ICanvasCallbacksMap = ICanvasCallbacksMap, S extends ICanvasStaticProps = ICanvasStaticProps, M extends ICanvasMutableProps = ICanvasMutableProps> extends Module<C, S, M> { /** Get default static properties */ _getStatic(): TRequiredProps<S>; /** Get default mutable properties */ _getMutable(): TRequiredProps<M>; /** The canvas element created for rendering */ private _canvas; /** The 2D rendering context. */ private _ctx; /** The current width of the canvas, considering the device pixel ratio (DPR) */ private _width; /** The current height of the canvas, considering the device pixel ratio (DPR) */ private _height; /** The current device pixel ratio (DPR) */ private _dpr; /** * Constructor for the Ctx2D class. */ constructor(props?: S & M & TModuleOnCallbacksProps<C, Canvas<C, S, M>>, onCallbacks?: TModuleOnCallbacksProps<C, Canvas<C, S, M>>); /** The canvas element instance. */ get canvas(): HTMLCanvasElement; /** Returns the 2D rendering context */ get ctx(): CanvasRenderingContext2D; /** Canvas width (DPR applied). */ get width(): number; /** Width without DPR scaling. */ get offsetWidth(): number; /** Canvas height (DPR applied). */ get height(): number; /** Height without DPR scaling. */ get offsetHeight(): number; /** Current device pixel ratio. */ get dpr(): number; /** Checks if the canvas is ready to render. */ get canRender(): boolean; /** Handle property mutations */ protected _handleProps(props: Partial<M>): void; /** Set events */ protected _setEvents(): void; /** Triggers a canvas resize based on container or viewport dimensions. */ resize(): void; /** * Renders content on the canvas if it's ready. * * @param render - A function that performs the actual rendering on the canvas. */ render(render: TCanvasRender): void; /** Destroys the canvas. */ protected _destroy(): void; } //# sourceMappingURL=index.d.ts.map