import { Ref } from 'vue'; import { HousePlannerCanvas } from './canvas'; import { Layer, Vec2 } from './interfaces'; 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) { this.manager.tools.selectLayer( initialData[initialData.findIndex((layer) => layer.active)] ); this.manager.tools.setInitialSelection(); this.manager.tools.setTool('move'); } this.manager.draw(); return () => this.cleanUp(); } cleanUp() { this.manager?.cleanUp(); } }