phantasmal-world/src/core/gui/RendererWidget.ts

34 lines
773 B
TypeScript
Raw Normal View History

import { ResizableWidget } from "./ResizableWidget";
import { Renderer } from "../rendering/Renderer";
import { div } from "./dom";
2019-08-20 04:56:40 +08:00
export class RendererWidget extends ResizableWidget {
readonly element = div({ className: "core_RendererWidget" });
2019-08-20 04:56:40 +08:00
constructor(private renderer: Renderer) {
super();
2019-08-20 04:56:40 +08:00
this.element.append(renderer.canvas_element);
2019-08-20 04:56:40 +08:00
this.disposable(renderer);
this.finalize_construction();
}
start_rendering(): void {
this.renderer.start_rendering();
}
2019-08-20 04:56:40 +08:00
stop_rendering(): void {
this.renderer.stop_rendering();
2019-08-20 04:56:40 +08:00
}
resize(width: number, height: number): this {
super.resize(width, height);
this.renderer.set_size(width, height);
return this;
}
}