import {UI} from "./UI"; import {TurnThePage} from "../TurnThePage"; import {FlipSetting} from "../Settings"; /** * UI for canvas mode */ export class CanvasUI extends UI { private readonly canvas: HTMLCanvasElement; constructor(inBlock: HTMLElement, app: TurnThePage, setting: FlipSetting) { super(inBlock, app, setting); this.wrapper.innerHTML = ''; this.canvas = inBlock.querySelectorAll('canvas')[0]; this.distElement = this.canvas; this.resizeCanvas(); this.setHandlers(); } private resizeCanvas(): void { const cs = getComputedStyle(this.canvas); const width = parseInt(cs.getPropertyValue('width'), 10); const height = parseInt(cs.getPropertyValue('height'), 10); this.canvas.width = width; this.canvas.height = height; } /** * Get canvas element */ public getCanvas(): HTMLCanvasElement { return this.canvas; } public update(): void { this.resizeCanvas(); this.app.getRender().update(); } }