(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
/// <reference path="../../typescript/typescriptAPI/TypeScriptAPIPlugin.d.ts" />
"use strict";

SupCore.system.registerPlugin("typescriptAPI", "Sup.Font", {
    code: "namespace Sup {\n  let canvas = window.document.createElement(\"canvas\");\n  canvas.width = 1; canvas.height = 1;\n\n  export class Font extends Asset {\n    getTextWidth(text) {\n      if (this.__inner.isBitmap) {\n        return text.length * this.__inner.gridWidth / this.__inner.pixelsPerUnit;\n      } else {\n        let ctx = canvas.getContext(\"2d\");\n        ctx.font = `${this.__inner.size}px ${this.__inner.name}`;\n        return ctx.measureText(text).width / this.__inner.pixelsPerUnit;\n      }\n    }\n  }\n}\n",
    defs: "declare namespace Sup {\n  class Font extends Asset {\n    getTextWidth(text: string): number;\n  }\n}\n",
});
SupCore.system.registerPlugin("typescriptAPI", "TextRenderer", {
    code: "namespace Sup {\n  export class TextRenderer extends Sup.ActorComponent {\n    constructor(actor: Actor, text: string|number, pathOrAsset: string|Font, options: any={}) {\n      super(actor);\n      this.__inner = new SupEngine.componentClasses.TextRenderer(this.actor.__inner);\n\n      if (options.color != null) options.color = options.color.getHexString();\n      this.__inner.setOptions(options);\n      if (text != null) this.__inner.setText(`${text}`);\n      if (pathOrAsset != null) this.setFont(pathOrAsset);\n\n      this.__inner.__outer = this;\n      this.actor.textRenderer = this;\n    }\n    destroy() {\n      this.actor.textRenderer = null;\n      super.destroy();\n    }\n\n    getFont() { return this.__inner.font.__outer; }\n    setFont(pathOrAsset: string|Font) {\n      let fontAsset = (typeof pathOrAsset === \"string\") ? get(pathOrAsset, Font) : <Font>pathOrAsset;\n      this.__inner.setFont(fontAsset.__inner);\n      return this;\n    }\n    getText() { return this.__inner.text; }\n    setText(text: string|number) {\n      this.__inner.setText(`${text}`);\n      return this;\n    }\n    getColor() {\n      var color = (this.__inner.options.color != null) ? this.__inner.options.color : this.__inner.font.color;\n      return new Sup.Color(1, 1, 1).setHex(parseInt(color, 16));\n    }\n    setColor(r, g, b) {\n      let color;\n      if (g == null && b == null) color = r;\n      else color = new Sup.Color(r, g, b);\n\n      var options = this.__inner.options;\n      options.color = color.getHexString();\n      this.__inner.setOptions(options);\n      return this;\n    }\n    getAlignment() { return this.__inner.options.alignment; }\n    setAlignment(alignment) {\n      var options = this.__inner.options;\n      options.alignment = alignment;\n      this.__inner.setOptions(options);\n      return this;\n    }\n    getVerticalAlignment() { return this.__inner.options.verticalAlignment; }\n    setVerticalAlignment(verticalAlignment) {\n      var options = this.__inner.options;\n      options.verticalAlignment = verticalAlignment;\n      this.__inner.setOptions(options);\n      return this;\n    }\n    getSize() {\n      var size = (this.__inner.options.size != null) ? this.__inner.options.size : this.__inner.font.size;\n      return size;\n    }\n    setSize(size) {\n      var options = this.__inner.options;\n      options.size = size;\n      this.__inner.setOptions(options);\n      return this;\n    }\n    getOpacity() { return this.__inner.opacity; }\n    setOpacity(opacity) {\n      this.__inner.setOpacity(opacity);\n      return this;\n    }\n  }\n}\n",
    defs: "declare namespace Sup {\n  class TextRenderer extends ActorComponent {\n    constructor(actor: Actor, text?: string|number, pathOrAsset?: string|Font, options?: {alignment?: string; verticalAlignment?: string; size?: number; color?: Color;});\n\n    getFont(): Font;\n    setFont(pathOrAsset: string|Font): TextRenderer;\n    getText(): string;\n    setText(text: string|number): TextRenderer;\n    getColor(): Color;\n    setColor(color: Color): TextRenderer;\n    setColor(r: number, g: number, b: number): TextRenderer;\n    getAlignment(): string;\n    setAlignment(alignment: string): TextRenderer;\n    getVerticalAlignment(): string;\n    setVerticalAlignment(verticalAlignment: string): TextRenderer;\n    getSize(): number;\n    setSize(size: number): TextRenderer;\n    getOpacity(): number;\n    setOpacity(opacity: number): TextRenderer;\n  }\n}\n",
    exposeActorComponent: { propertyName: "textRenderer", className: "Sup.TextRenderer" }
});

},{}]},{},[1]);
