dom-helpers.ts

39 lines | 1.307 kB Blame History Raw Download
import { RenderCanvas } from "../elements/render-canvas/render-canvas";

export function clear() {

}

export function rect(x: number, y: number, width: number, height: number): void {
    var renderCanvas = <RenderCanvas>document.getElementsByTagName("render-canvas")[0];
    renderCanvas.drawRect(x, y, width, height);
}

export function box(x: number, y: number, width: number, height: number): void {
    var renderCanvas = <RenderCanvas>document.getElementsByTagName("render-canvas")[0];
    renderCanvas.queueRect(x, y, width, height);
}

export function getWidth(): number {
    var renderCanvas = <RenderCanvas>document.getElementsByTagName("render-canvas")[0];
    return renderCanvas.units.width;
}

export function getHeight(): number {
    var renderCanvas = <RenderCanvas>document.getElementsByTagName("render-canvas")[0];
    return renderCanvas.units.height;
}

export function getCenter(): number {
    var renderCanvas = <RenderCanvas>document.getElementsByTagName("render-canvas")[0];
    return renderCanvas.units.height / 2;
}

export function getRandom(min: number, max: number): number {
    return Math.floor(Math.random() * (max - min + 1) + min);
}

export function executeDrawQueue() {
    var renderCanvas = <RenderCanvas>document.getElementsByTagName("render-canvas")[0];
    renderCanvas.executeDrawQueue();
}