import { HousePlannerCanvasHistory } from './history'; import { LayerObjectType } from './types'; export type Vec2 = [number, number]; export type Vec2Box = [Vec2, Vec2]; export interface LineSegment { start?: Vec2; end: Vec2; } export interface BezierSegment extends LineSegment { startControl: Vec2; endControl: Vec2; } export interface LayerObject { id: number; databaseId?: number; name: string; visible: boolean; selected: boolean; type: LayerObjectType; } export interface Line extends LayerObject { segments: LineSegment[]; width: number; color: string; render?: Path2D; lineCap?: CanvasLineCap; lineJoin?: CanvasLineJoin; closed?: boolean; lineDash?: number[]; } export interface Layer { id: number; contents: LayerObject[]; name: string; color: string; visible: boolean; active: boolean; } export interface History { object: T; property: keyof T; value: unknown; } export interface UpdateEvent { event: string; object?: LayerObject; } export interface ToolEvent { primary: string; secondary?: unknown; } export interface RepositionEvent { position: Vec2; zoom: number; } export interface ICanvasToolMouseEvents { mouseDown(targetObject?: LayerObject): void; mouseMoved(mouse: Vec2, offset: Vec2, mouseAbsolute: Vec2): void; mouseUp(moved: boolean): void; } export interface ICanvasToolkit extends ICanvasToolMouseEvents { history: HousePlannerCanvasHistory; drawHighlights(): void; drawControls(): void; cleanUp(): void; onKeyDown(e: KeyboardEvent): void; onKeyUp(e: KeyboardEvent): void; getMousedObject(): LayerObject | null; } export interface ICanvasToolBase extends ICanvasToolMouseEvents { name: string; subTool: U | undefined; drawHighlights(): void; drawControls(): void; enterPress(e: KeyboardEvent): void; escapePress(e: KeyboardEvent): void; setSubTool(subTool?: U): void; activate(): void; deactivate(): void; selectionDeleted(): void; selectionChanged(selection: LayerObject[]): void; emitEvent(e: CustomEvent): void; isToolCancelable(): boolean; }