import { Color } from "@dt/core-ui"; import { PointLocation, Size } from "../../../ImageViewer/Models"; import { BasePaintObject } from "./BasePaintObject"; import { PaintObjectParameters } from "../../../ImageViewer/Layers"; import { ImageAlignment } from "./ObjectTypes"; import { Bounds } from "../../../ImageViewer/Models/SelectionBoxTypes"; export declare class ImagePaintObject extends BasePaintObject<'image'> { insertImageArgs: { imageData: Uint8Array; img?: HTMLImageElement; } | null; paintLayerSize: { width: number; height: number; }; readonly opacity: number; readonly borderWidth: number; readonly borderColor: Color; readonly keepAspectRatio: boolean; borderRadius: number; /** * Current image alignment. */ alignment: ImageAlignment; /** * Skew (shear) angles in degrees. * skewX shears along the X-axis (horizontal skew). * skewY shears along the Y-axis (vertical skew). * Positive values follow the standard canvas transform convention. * NOTE: Values are clamped to a safe range to avoid extreme tangents. */ skewX: number; skewY: number; constructor(position: PointLocation, insertImageArgs: { imageData: Uint8Array; img?: HTMLImageElement; } | null, paintLayerSize: { width: number; height: number; }, opacity: number, borderWidth: number, borderColor: Color, keepAspectRatio: boolean, borderRadius?: number, alignment?: ImageAlignment, /** * Optional skew in degrees along X and Y. Defaults to no skew. * Placed last to keep backward compatibility with existing call sites. */ skewX?: number, skewY?: number); /** * Returns the additional padding (in pixels) required around the object * to accommodate visual effects such as line caps and skew. * The padding is calculated based on line width and the maximum shift * introduced by skewing the object. */ get canvasPadding(): number; /** * Calculates default image size based on canvas dimensions * @param canvasSize - Available canvas dimensions {width, height} * @returns Calculated image size {width, height} (60% of canvas or smaller if image is small) */ private calcDefaultSize; /** * Calculates the drawing offset based on alignment and available space * @param imgWidth - Actual image width * @param imgHeight - Actual image height * @param bounds - Available drawing area * @returns Object containing x and y offsets */ private calculateDrawingOffset; /** * Extracts image dimensions from binary image data synchronously * @param imageData - Uint8Array containing image data * @returns Size object with width/height or null if unsupported format */ private getImageDimensions; get bounds(): Bounds; set bounds(bounds: Bounds); private roundRectPath; /** * Asynchronously draws the image object on the canvas with proper alignment * @param destCtx - Destination canvas context * @param mainCtx - Main canvas context (unused in this implementation) * @param backCtx - Background canvas context (unused in this implementation) * @param params - Optional drawing parameters */ draw(destCtx: CanvasRenderingContext2D, mainCtx: CanvasRenderingContext2D, backCtx: CanvasRenderingContext2D, params?: PaintObjectParameters): Promise; /** * Calculates drawing dimensions while maintaining aspect ratio * @param img - Source image element * @param bounds - Available drawing area * @returns Calculated width and height */ private calculateImageSize; /** * Draws the background rectangle (for rounded corners support) * @param destCtx - Drawing context * @param bounds - Drawing boundaries */ private drawBackground; /** * Draws the border around the image * @param destCtx - Drawing context * @param bounds - Drawing boundaries */ private drawBorder; /** * Gets the content dimensions of the object, handling image sizing and aspect ratio preservation * @param ctx - Canvas context used for measurements * @returns Size object containing calculated width and height */ getContentSize(ctx: CanvasRenderingContext2D): Size; setProperty(propertyName: any, value: any): boolean; /** * Applies a shear transform to the current context using the configured skewX/skewY angles. * Order of operations: existing transforms (translate/rotate/scale) -> skew -> draw. */ private applySkewTransform; /** * Converts degrees to radians. */ private degToRad; /** * Clamps skew degrees to a safe range to avoid undefined tan() (near 90°). * Safe practical range is [-85°, 85°]. */ private clampSkew; /** * Coerces unknown input to a number with a fallback. */ private toNumberSafe; }