text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).rexcanvas=e()}(this,function(){"use strict";function r(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function h(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function a(a){return function(){var t,e,i,r=s(a);if(function(){if("undefined"!=typeof Reflect&&Reflect.construct&&!Reflect.construct.sham){if("function"==typeof Proxy)return 1;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),1}catch(t){return}}}()){var n=s(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return e=this,!(i=t)||"object"!=typeof i&&"function"!=typeof i?h(e):i}}var c=Phaser.Renderer.WebGL.Utils,t={renderWebGL:function(t,e,i,r,n){if(e.dirty&&(e.updateTexture(),e.dirty=!1),0!==e.width&&0!==e.height){var a=e.frame,s=a.width,o=a.height,h=c.getTintAppendFloatAlpha;this.pipeline.batchTexture(e,a.glTexture,s,o,e.x,e.y,s/e.resolution,o/e.resolution,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,s,o,h(e._tintTL,r.alpha*e._alphaTL),h(e._tintTR,r.alpha*e._alphaTR),h(e._tintBL,r.alpha*e._alphaBL),h(e._tintBR,r.alpha*e._alphaBR),e._isTinted&&e.tintFill,0,0,r,n)}},renderCanvas:function(t,e,i,r,n){0!==e.width&&0!==e.height&&t.batchSprite(e,e.frame,r,n)}},o=Phaser.Display.Color,e={clear:function(){return this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.dirty=!0,this},fill:function(t){return this.context.fillStyle=t,this.context.fillRect(0,0,this.canvas.width,this.canvas.height),this.dirty=!0,this},loadFromURL:function(t,e){var i=this,r=new Image;return r.onload=function(){i.width!==r.width||i.height!==r.height?i.resize(r.width,r.height):i.clear(),i.context.drawImage(r,0,0),i.updateTexture(),e&&e(),r.onload=null,r.src="",r.remove()},r.src=t,this},loadFromURLPromise:function(i){var r=this;return new Promise(function(t,e){r.loadFromURL(i,t)})},getDataURL:function(t,e){return this.canvas.toDataURL(t,e)},getPixel:function(t,e,i){void 0===i&&(i=new o);var r=this.context.getImageData(t,e,1,1);return i.setTo(r.data[0],r.data[1],r.data[2],r.data[3]),i},setPixel:function(t,e,i,r,n,a){if("number"!=typeof i){var s=i;i=s.red,r=s.green,n=s.blue,a=s.alpha}void 0===a&&(a=0!==i||0!==r||0!==n?255:0);var o=this.context.createImageData(1,1);return o.data[0]=i,o.data[1]=r,o.data[2]=n,o.data[3]=a,this.context.putImageData(o,t,e),this.dirty=!0,this}},i={updateTexture:function(t,e){t&&(e?t.call(e,this.canvas,this.context):t(this.canvas,this.context)),this.canvas.width===this.frame.width&&this.canvas.height===this.frame.height||this.frame.setSize(this.canvas.width,this.canvas.height),this.renderer.gl&&(this.frame.source.glTexture=this.renderer.canvasToTexture(this.canvas,this.frame.source.glTexture,!0),this.frame.glTexture=this.frame.source.glTexture),this.dirty=!1;var i=this.input;return i&&!i.customHitArea&&(i.hitArea.width=this.width,i.hitArea.height=this.height),this},generateTexture:function(t,e,i,r,n){var a,s=this.canvas,o=this.scene.sys,h=o.game.renderer;void 0===e&&(e=0),void 0===i&&(i=0),void 0===r?r=s.width:r*=this.resolution,void 0===n?n=s.height:n*=this.resolution;var c=(a=o.textures.exists(t)?o.textures.get(t):o.textures.createCanvas(t,r,n)).getSourceImage();c.width!==r&&(c.width=r),c.height!==n&&(c.height=n);var u=c.getContext("2d");return u.clearRect(0,0,r,n),u.drawImage(s,e,i,r,n),h.gl&&a&&h.canvasToTexture(c,a.source[0].glTexture,!0,0),this},loadTexture:function(t,e){var i=this.scene.textures.getFrame(t,e);return i&&(this.width!==i.cutWidth||this.height!==i.cutHeight?this.resize(i.cutWidth,i.cutHeight):this.clear(),this.context.drawImage(i.source.image,i.cutX,i.cutY,i.cutWidth,i.cutHeight,0,0,this.canvas.width,this.canvas.height),this.dirty=!0),this}},u=Phaser.Display.Canvas.CanvasPool,l=Phaser.GameObjects.GameObject,d=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&&n(t,e)}(o,l);var t,e,i,s=a(o);function o(t,e,i,r,n){var a;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=1),(a=s.call(this,t,"rexCanvas")).renderer=t.sys.game.renderer,a.resolution=t.sys.game.config.resolution,a.canvas=u.create(h(a),a.resolution*r,a.resolution*n),a.context=a.canvas.getContext("2d"),a.dirty=!1,a.setPosition(e,i),a.setSize(r,n),a.setOrigin(.5,.5),a.initPipeline(),a._crop=a.resetCropObject(),a.texture=t.sys.textures.addCanvas(null,a.canvas,!0),a.frame=a.texture.get(),a.frame.source.resolution=a.resolution,a.renderer.gl&&(a.renderer.deleteTexture(a.frame.source.glTexture),a.frame.source.glTexture=null),a.dirty=!0,t.sys.game.events.on("contextrestored",function(){this.dirty=!0},h(a)),a}return t=o,(e=[{key:"getCanvas",value:function(t){return t||(this.dirty=!0),this.canvas}},{key:"needRedraw",value:function(){return this.dirty=!0,this}},{key:"preDestroy",value:function(){u.remove(this.canvas)}},{key:"resize",value:function(t,e){return this.width===t&&this.height===e||(this.setSize(t,e).updateDisplayOrigin(),t*=this.resolution,e*=this.resolution,t=Math.max(Math.ceil(t),1),e=Math.max(Math.ceil(e),1),this.canvas.width=t,this.canvas.height=e,this.frame.setSize(t,e),this.dirty=!0),this}}])&&r(t.prototype,e),i&&r(t,i),o}(),f=Phaser.GameObjects.Components;return Phaser.Class.mixin(d,[f.Alpha,f.BlendMode,f.ComputedSize,f.Crop,f.Depth,f.Flip,f.GetBounds,f.Mask,f.Origin,f.Pipeline,f.ScrollFactor,f.Tint,f.Transform,f.Visible,t,e,i]),d});
  