import { Ref } from 'vue'; import { HousePlannerCanvas } from './canvas'; import { Layer, Vec2 } from './interfaces'; import { HousePlannerCanvasTools } from './tools'; export class HousePlanner { public canvas!: HTMLCanvasElement; public manager?: HousePlannerCanvas; initialize( canvas: HTMLCanvasElement, initialData: Layer[], canvasDim: Vec2, canvasPos: Vec2, canvasZoom = 1, editable = true ) { this.canvas = canvas; this.manager = new HousePlannerCanvas( canvas, canvasDim, canvasPos, canvasZoom, editable ); this.manager.layers = initialData; if (editable && this.manager.tools) { const stdToolkit = this.manager.tools as HousePlannerCanvasTools; stdToolkit.selectLayer( initialData[initialData.findIndex((layer) => layer.active)] ); stdToolkit.setInitialSelection(); stdToolkit.setTool('move'); } this.manager.draw(); } cleanUp() { this.manager?.cleanUp(); } }