export interface CropRect { x: number; y: number; w: number; h: number; } export type CropHandle = 'nw' | 'ne' | 'sw' | 'se'; export interface Point { x: number; y: number; } export interface WrappedText { lines: string[]; fontSize: number; } /** An image MIME type a canvas can encode to (what `toBlob` and `toDataURL` take). */ export type CanvasFormat = 'image/png' | 'image/jpeg' | 'image/webp'; /** Clamps crop dimensions and position to stay within image bounds. */ export declare function fitCropToImage(crop: CropRect, imgW: number, imgH: number, minSize?: number): CropRect; /** Centered crop rect that fills the image while preserving `ratio` (w/h). */ export declare function createCenteredCrop(imgW: number, imgH: number, ratio: number): CropRect; /** Translates a crop by `(dx, dy)` while keeping it within the image. */ export declare function moveCrop(start: CropRect, dx: number, dy: number, imgW: number, imgH: number): CropRect; /** Resizes a crop from a corner handle, maintaining the given aspect ratio. */ export declare function resizeCrop(start: CropRect, dx: number, ratio: number, handle: CropHandle, imgW: number, imgH: number, minSize?: number): CropRect; /** Maps pointer client coords to natural image coordinates given an element's bounding rect. */ export declare function pointerToNatural(clientX: number, clientY: number, rect: DOMRect, imageWidth: number): Point; /** Wraps text to lines that fit within `maxWidth`, respecting hard newlines. */ export declare function wrapTextForWidth(ctx: CanvasRenderingContext2D, text: string, maxWidth: number): string[]; /** * Binary-searches for the largest font size in `[baseFontSize * 0.35, baseFontSize]` * such that the wrapped text fits within `maxWidth × maxHeight`. */ export declare function fitText(ctx: CanvasRenderingContext2D, text: string, maxWidth: number, maxHeight: number, baseFontSize: number, font: string, fontWeight?: number | string): WrappedText; export interface LowQualityOptions { /** Contrast boost factor in [0, 1]. Default 0.35. */ contrast?: number; /** Number of posterize levels. Default 6. */ levels?: number; /** Per-channel noise amplitude. Default 28. */ noise?: number; } /** Applies posterization + noise for a retro/low-quality aesthetic; throws a RangeError for `levels` below 2 or non-finite (one level has no step), clamps `contrast` to [0, 1], and treats a non-finite `noise` as 0. */ export declare function applyLowQuality(ctx: CanvasRenderingContext2D, width: number, height: number, options?: LowQualityOptions): void; export declare function canvasExtension(format: CanvasFormat): string; /** Downloads the canvas as a file. */ export declare function downloadCanvas(canvas: HTMLCanvasElement, filename: string, format?: CanvasFormat, quality?: number): void; /** Copies the canvas to the clipboard as an image. */ export declare function copyCanvasToClipboard(canvas: HTMLCanvasElement, format?: CanvasFormat, quality?: number): Promise; //# sourceMappingURL=canvas.d.ts.map