text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).rexcanvasdataplugin=e()}(this,function(){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function t(t,e,r){return e&&i(t.prototype,e),r&&i(t,r),t}function o(t){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function a(i){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=o(i);if(n){var r=o(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return u(this,t)}}function f(t,e,r){return(f="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=o(t)););return t}(t,e);if(i){var n=Object.getOwnPropertyDescriptor(i,e);return n.get?n.get.call(r):n.value}})(t,e,r||t)}var c=Phaser.Display.Color,e={rgbaToColor32:function(t,e,r,i){return i<<24|t<<16|e<<8|r},color32ToColorInt:function(t){return 16777215&t},color32ToAlpha:function(t){return t>>>24},color32ToColorObject:function(t,e){var r=t>>16&255,i=t>>8&255,n=255&t,o=t>>24&255;return void 0===e?e=new c(r,n,i,o):e.setTo(r,n,i,o),e}},v=function(){function i(t,e,r){n(this,i),void 0===e&&(e=0),void 0===r&&(r=e),this.width=e,this.height=r,this.buffer=new t(e*r)}return t(i,[{key:"getOffset",value:function(t,e){return e*this.width+t}},{key:"get",value:function(t,e){var r;return r=2===arguments.length?this.getOffset(t,e):t,this.buffer.get(r)}},{key:"set",value:function(t,e,r){var i;return 3===arguments.length?i=this.getOffset(t,e):(i=t,r=e),this.buffer.set(i,r),this}},{key:"fill",value:function(t,e,r,i,n,o,s){if("number"==typeof t){var u=t;this.buffer.fill(u)}else{void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=t.width-e),void 0===n&&(n=t.height-r),this.resize(i,n);for(var a,f=t.getContext("2d").getImageData(e,r,i,n).data,c=0,h=f.length/4;c<h;c++)a=4*c,u=s?o.call(s,f,a):o(f,a),this.set(c,u)}return this}},{key:"clear",value:function(){return this.fill(0),this}},{key:"resize",value:function(t,e){return this.width===t&&this.height===e||(this.width=t,this.height=e,this.buffer.resize(t*e)),this}},{key:"forEach",value:function(t,e,r){var i;void 0===r&&(r=!1);for(var n=0,o=this.height;n<o;n++)for(var s=0,u=this.width;s<u;s++)i=this.get(s,n),r&&(0===i||!1===i)||(e?t.call(e,i,s,n,this):t(i,s,n,this));return this}},{key:"forEachNonZero",value:function(t,e){return this.forEach(t,e,!0),this}}]),i}();Object.assign(v.prototype,e);function d(t,e,r,i,n,o,s,u,a){return void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=t.width-e),void 0===n&&(n=t.height-r),void 0===a&&(a=new v(o,i,n)),a.fill(t,e,r,i,n,s,u),a}function h(t,e){return 0<t[e+3]}function r(t,e,r){e instanceof v&&(r=e,e=void 0);var i=p(e,"x",void 0),n=p(e,"y",void 0),o=p(e,"width",void 0),s=p(e,"height",void 0);return d(t.canvas,i,n,o,s,l,h,void 0,r)}function y(t,e){return t[e+3]<<24|t[e+0]<<16|t[e+1]<<8|t[e+2]}var l=function(){function e(t){n(this,e),this.resize(t)}return t(e,[{key:"get",value:function(t){var e=t>>3,r=1<<t%8;return 0<(this._bin[e]&r)}},{key:"set",value:function(t,e){var r=t>>3,i=1<<t%8;return e?this._bin[r]|=i:(i^=255,this._bin[r]&=i),this}},{key:"fill",value:function(t){t=t?255:0;for(var e=0,r=this._rows;e<r;e++)this._bin[e]=t;return this}},{key:"resize",value:function(t){var e=1+(t>>3);return e!==this._rows&&(this._rows=e,this._buf=new ArrayBuffer(this._rows),this._bin=new Uint8Array(this._buf)),this}}]),e}(),p=Phaser.Utils.Objects.GetValue,g=function(){function e(t){n(this,e),this.resize(t)}return t(e,[{key:"get",value:function(t){return this._colors[t]}},{key:"set",value:function(t,e){return this._colors[t]=e,this}},{key:"fill",value:function(t){for(var e=0,r=this._rows;e<r;e++)this._colors[e]=t;return this}},{key:"resize",value:function(t){return t!==this._rows&&(this._rows=t,this._buf=new ArrayBuffer(4*this._rows),this._colors=new Uint32Array(this._buf)),this}}]),e}(),b=Phaser.GameObjects.GameObject,w=Phaser.Utils.Objects.GetValue,_=Phaser.Display.Canvas.CanvasPool,m={textObjectToBitmap:r,canvasObjectToBitmap:r,textureTColorMap:function(t,e,r,i){var n;"string"==typeof t?("string"!=typeof e&&(i=r,r=e,e=void 0),n=this.textureManager.getFrame(t,e)):(n=t instanceof b?t.frame:t,i=r,r=e),r instanceof v&&(i=r,r=void 0);var o,s,u=void 0!==this._tmpCanvas,a=u?this._tmpCanvas:_.create2D(this,void 0,void 0,void 0,!0),f=w(r,"x",void 0),c=w(r,"y",void 0),h=w(r,"width",void 0),l=w(r,"height",void 0);return i=d((o=n,(s=a).width=o.cutWidth,s.height=o.cutHeight,s.getContext("2d").drawImage(o.source.image,o.cutX,o.cutY,o.cutWidth,o.cutHeight),s),f,c,h,l,g,y,void 0,i),u?(a.width=1,a.height=1):_.remove(a),i}},O=Phaser.Display.Canvas.CanvasPool,k=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}(r,Phaser.Plugins.BasePlugin);var e=a(r);function r(t){return n(this,r),e.call(this,t)}return t(r,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this),this._tmpCanvas=O.create2D(this)}},{key:"destroy",value:function(){O.remove(this._tmpCanvas),this._tmpCanvas=void 0,f(o(r.prototype),"destroy",this).call(this)}},{key:"textureManager",get:function(){return this.game.textures}}]),r}();return Object.assign(k.prototype,m),k});
  