import { Color } from '@dt/core-ui'; import { IPaintObject, PaintCommandName, PaintObjectParameters, PaintObjectPropertyName, PaintObjectType } from '../../../ImageViewer/Layers'; import { Bounds, PointLocation, Size } from '../../../ImageViewer/Models/SelectionBoxTypes'; /** * Abstract base class that provides core functionality for all paint objects. * Implements the IPaintObject interface with common properties and methods. * @template T - The specific type of paint object (e.g., 'rectangle', 'line') */ export declare abstract class BasePaintObject implements IPaintObject { type: T; name: PaintCommandName; startPosition: PointLocation; lineColor: Color; lineWidth: number; fillColor: Color; opacity: number; /** The bounding rectangle of the object in canvas coordinates */ protected _bounds: Bounds; /** The shadow blur radius applied to the object */ protected _shadowBlur: number; /** The color of the shadow applied to the object */ protected _shadowColor: string; /** The end position of the object (used primarily for line objects) */ protected _endPosition: PointLocation; /** * Creates a new BasePaintObject instance * @param type - The type identifier of the paint object * @param name - The display name of the paint object * @param startPosition - The starting position of the object * @param lineColor - The stroke color of the object * @param lineWidth - The stroke width in pixels * @param fillColor - The fill color of the object * @param opacity - The opacity level (0-100) */ constructor(type: T, name: PaintCommandName, startPosition: PointLocation, lineColor: Color, lineWidth: number, fillColor: Color, opacity: number); /** * Applies saved default values after object initialization. * Must be called explicitly in derived class constructors AFTER all properties are initialized. * * @example * class Derived extends Base { * constructor() { * super(); * // Initialize properties here * this.foo = 'bar'; * this.initializeWithDefaults(); // Call after initialization * } * } */ protected initializeWithDefaults(): void; /** * Returns the additional padding (in pixels) required around the object * to accommodate all visual elements like styled line caps. * This is useful for properly sizing the canvas when rendering this object. */ get canvasPadding(): number; /** * Gets the end position of the object (defaults to position if not set) * @returns The end position coordinates */ get endPosition(): PointLocation; /** * Sets the end position of the object * @param pos - The new end position coordinates */ set endPosition(pos: PointLocation); /** * Gets the bounding rectangle of the object * @returns The current bounds of the object */ get bounds(): Bounds; /** * Sets the bounding rectangle of the object * @param bounds - The new bounding rectangle */ set bounds(bounds: Bounds); protected setBoundsInternal(bounds: Bounds): void; /** * The rotation angle of the object in degrees (0-360). */ rotation: number; /** * Applies base styling properties to a canvas context * @param ctx - The canvas context to style */ protected applyBaseStyles(ctx: CanvasRenderingContext2D): void; /** * Applies position and rotation transformations to a canvas context. * * In design mode (when editing objects), each object is rendered on its own canvas. * Padding is applied around the canvas to account for effects like shadows or outlines. * Rotation in this mode is handled at the DOM level (via CSS transform), so canvas * rotation is skipped. * * In runtime (final rendering), all objects are drawn on a single shared canvas. * In this case, padding is not applied and rotation is handled via canvas transforms. * * @param ctx - The canvas rendering context to transform. * @param params - Optional rendering parameters: * - isDesignTime: Whether the object is being rendered in design/edit mode. * When true, canvas padding is applied and rotation is skipped. * * Transformation steps: * 1. Translate to the center of the object (with optional design-time padding). * 2. Apply rotation (only in runtime mode). * 3. Translate back so drawing starts from the top-left corner. * * @see PaintObjectDesigner.setBoundsInternal for CSS-based design-time rotation. */ protected transformContext(ctx: CanvasRenderingContext2D, params?: PaintObjectParameters): void; /** * Abstract method to render the object to canvas contexts * @param destCtx - The primary drawing context * @param mainCtx - The main canvas context (for composite operations) * @param backCtx - The background context (for layered rendering) * @param params - Optional rendering parameters */ abstract draw(destCtx: CanvasRenderingContext2D, mainCtx: CanvasRenderingContext2D, backCtx: CanvasRenderingContext2D, params?: PaintObjectParameters): Promise; /** * Gets the content dimensions of the object * @param ctx - Canvas context used for measurements * @returns Size object containing width and height */ getContentSize(ctx: CanvasRenderingContext2D): Size; /** * Gets the value of a specified property * @template K - The type of the property name * @param propertyName - The name of the property to retrieve * @returns The property value * @throws {Error} When the property does not exist */ getProperty(propertyName: K): any; /** * Sets the value of a specified property * @template K - The type of the property name * @param propertyName - The name of the property to set * @param value - The new value for the property * @returns True if the property was changed, false otherwise */ setProperty(propertyName: K, value: any): boolean; /** * Resets all user-modified properties of the object * back to their registered factory default values. */ resetToFactoryDefaults(): void; protected isBoundsEqual(a?: Bounds, b?: Bounds): boolean; }