import { HousePlannerCanvas } from './canvas'; import { Layer, Vec2, Vec2Box } 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, boundingBox?: Vec2Box ): [number, Vec2] { 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(); if (boundingBox) { this.manager.initViewport(boundingBox); } return [this.manager.canvasZoom, this.manager.canvasPos]; } cleanUp() { this.manager?.cleanUp(); } }