UNPKG

phaser4-rex-plugins

Version:
2 lines (1 loc) 28.4 kB
var t,e;t=void 0,e=function(){var t={renderWebGL:function(t,e,s,i){if(e.dirty&&(e.updateTexture(),e.dirty=!1),0!==e.width&&0!==e.height){s.camera.addToRenderList(e);var r=e.customRenderNodes,a=e.defaultRenderNodes;(r.Submitter||a.Submitter).run(s,e,i,0,r.Texturer||a.Texturer,r.Transformer||a.Transformer)}},renderCanvas:function(t,e,s,i){e.dirty&&(e.updateTexture(),e.dirty=!1),0!==e.width&&0!==e.height&&(s.addToRenderList(e),t.batchSprite(e,e.frame,s,i))}};const e=Phaser.Display.Color;var s={clear(){return this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.dirty=!0,this},fill(t){return this.context.fillStyle=t,this.context.fillRect(0,0,this.canvas.width,this.canvas.height),this.dirty=!0,this},drawFrame(t,e,s,i,r,a,h,n,o,l){var u=this.scene.sys.textures.getFrame(t,e);if(!u)return this;var d=u.cutWidth,c=u.cutHeight;void 0===s&&(s=0),void 0===i&&(i=0),void 0===r&&(r=d),void 0===a&&(a=c),void 0===h&&(h=0),void 0===n&&(n=0),void 0===o&&(o=d),void 0===l&&(l=c);var v=u.cutX+h,g=u.cutY+n;return this.context.drawImage(u.source.image,v,g,o,l,s,i,r,a),this.dirty=!0,this},getDataURL(t,e){return this.canvas.toDataURL(t,e)},getPixel(t,s,i){void 0===i&&(i=new e);var r=this.context.getImageData(t,s,1,1);return i.setTo(r.data[0],r.data[1],r.data[2],r.data[3]),i},setPixel(t,e,s,i,r,a){if("number"!=typeof s){var h=s;s=h.red,i=h.green,r=h.blue,a=h.alpha}void 0===a&&(a=0!==s||0!==i||0!==r?255:0);var n=this.context.createImageData(1,1);return n.data[0]=s,n.data[1]=i,n.data[2]=r,n.data[3]=a,this.context.putImageData(n,t,e),this.dirty=!0,this}},i={updateTexture(t,e){var s=this.canvas,i=this.context;if(t){var r=this.resolution;1!==r&&(this.context.save(),this.context.scale(r,r)),e?t.call(e,s,i):t(s,i),1!==r&&this.context.restore()}var a=s.width,h=s.height;a===this.frame.width&&h===this.frame.height||(this.frame.setSize(a,h),this.frame.source.updateSize(a,h),this.frame.updateUVs()),this.renderer&&this.renderer.gl&&(this.frame.source.glTexture=this.renderer.canvasToTexture(s,this.frame.source.glTexture,!0),this.frame.glTexture.spectorMetadata={textureKey:"Canvas Game Object"}),this.dirty=!1;var n=this.input;return n&&!n.customHitArea&&(n.hitArea.width=this.width,n.hitArea.height=this.height),this},generateTexture(t,e,s,i,r){var a=this.canvas;return void 0===i?i=a.width:i*=this.resolution,void 0===r?r=a.height:r*=this.resolution,function(t,e,s,i,r,a,h){var n,o=t.sys.textures,l=t.renderer;void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=e.width),void 0===h&&(h=e.height);var u=(n=o.exists(s)?o.get(s):o.createCanvas(s,a,h)).getSourceImage();u.width!==a&&(u.width=a),u.height!==h&&(u.height=h);var d=u.getContext("2d",{willReadFrequently:!0});d.clearRect(0,0,a,h),d.drawImage(e,i,r,a,h),l.gl&&n&&l.canvasToTexture(u,n.source[0].glTexture,!0,0)}(this.scene,a,t,e,s,i,r),this},loadTexture(t,e){var s=this.scene.sys.textures.getFrame(t,e);return s?(this.width!==s.cutWidth||this.height!==s.cutHeight?this.setSize(s.cutWidth,s.cutHeight):this.clear(),this.drawFrame(t,e),this.dirty=!0,this):this}},r=!1;!function(t){if(!r){void 0===t&&(t=0);var e=Phaser.VERSION.split("."),s=parseInt(e[0]);if(4===s){var i=parseInt(e[1]);i<t&&console.error(`Minimum supported version : ${s}.${i}`)}else console.error(`Can't supported version : ${s}`);r=!0}}();const a=Phaser.Display.Canvas.CanvasPool,h=Phaser.GameObjects.GameObject,n=Phaser.Utils.String.UUID,o=Phaser.Renderer.WebGL.RenderNodes.Defaults.DefaultImageNodes;class l extends h{constructor(t,e,s,i,r,h){void 0===e&&(e=0),void 0===s&&(s=0),void 0===i&&(i=1),void 0===r&&(r=1),void 0===h&&(h=1),super(t,"rexCanvas"),this.renderer=t.sys.game.renderer,this._width=i,this._height=r,this.resolution=h,i=Math.max(Math.ceil(i*this.resolution),1),r=Math.max(Math.ceil(r*this.resolution),1),this.canvas=a.create(this,i,r),this.dirty=!1,this.setPosition(e,s),this.setOrigin(.5,.5),this.initRenderNodes(this._defaultRenderNodesMap),this._crop=this.resetCropObject(),this._textureKey=n(),this.texture=t.sys.textures.addCanvas(this._textureKey,this.canvas),this.context=this.texture.context,this.frame=this.texture.get(),this.frame.source.resolution=this.resolution,this.renderer&&this.renderer.gl&&(this.renderer.deleteTexture(this.frame.source.glTexture),this.frame.source.glTexture=null),this.dirty=!0}preDestroy(){a.remove(this.canvas),this.canvas=null,this.context=null;var t=this.texture;t&&t.destroy()}get _defaultRenderNodesMap(){return o}setResolution(t){if(this.resolution===t)return this;this.resolution=t;var e=Math.max(Math.ceil(this.width*t),1),s=Math.max(Math.ceil(this.height*t),1);return this.canvas.width=e,this.canvas.height=s,this.frame.source.resolution=t,this.dirty=!0,this}get width(){return this._width}set width(t){this.setSize(t,this._height)}get height(){return this._height}set height(t){this.setSize(this._width,t)}setCanvasSize(t,e){return this._width===t&&this._height===e||(this._width=t,this._height=e,this.updateDisplayOrigin(),t=Math.max(Math.ceil(t*this.resolution),1),e=Math.max(Math.ceil(e*this.resolution),1),this.canvas.width=t,this.canvas.height=e,this.frame.setSize(t,e),this.frame.source.updateSize(t,e),this.frame.updateUVs(),this.dirty=!0),this}setSize(t,e){return this.setCanvasSize(t,e),this}get displayWidth(){return this.scaleX*this._width}set displayWidth(t){this.scaleX=t/this._width}get displayHeight(){return this.scaleY*this._height}set displayHeight(t){this.scaleY=t/this._height}setDisplaySize(t,e){return this.displayWidth=t,this.displayHeight=e,this}getCanvas(t){return t||(this.dirty=!0),this.canvas}getContext(t){return t||(this.dirty=!0),this.context}needRedraw(){return this.dirty=!0,this}resize(t,e){return this.setSize(t,e),this}}const u=Phaser.GameObjects.Components;Phaser.Class.mixin(l,[u.Alpha,u.BlendMode,u.Crop,u.Depth,u.Flip,u.GetBounds,u.Lighting,u.Mask,u.Origin,u.RenderNodes,u.ScrollFactor,u.Tint,u.Transform,u.Visible,t,s,i]);const d=Phaser.Math.Linear,c=Phaser.Math.Percent;var v={setValue(t,e,s){return null==t||(void 0!==e&&(t=c(t,e,s)),this.value=t),this},addValue(t,e,s){return void 0!==e&&(t=c(t,e,s)),this.value+=t,this},getValue(t,e){var s=this.value;return void 0!==t&&void 0!==e&&(s=d(t,e,s)),s}},g={setEventEmitter(t,e){return void 0===e&&(e=Phaser.Events.EventEmitter),this._privateEE=!0===t||void 0===t,this._eventEmitter=this._privateEE?new e:t,this},destroyEventEmitter(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter(){return this._eventEmitter},on(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}};const p=Phaser.Scene;var m=function(t){return t instanceof p};const y=Phaser.Game;var k=function(t){return t instanceof y};const C=Phaser.Utils.Objects.GetValue;class x{constructor(t,e){this.setParent(t),this.isShutdown=!1,this.setEventEmitter(C(e,"eventEmitter",!0)),this.parent&&(this.parent===this.scene?this.scene.sys.events.once("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.once("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.once("destroy",this.onParentDestroy,this))}shutdown(t){this.isShutdown||(this.parent&&(this.parent===this.scene?this.scene.sys.events.off("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.off("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.off("destroy",this.onParentDestroy,this)),this.destroyEventEmitter(),this.parent=void 0,this.scene=void 0,this.game=void 0,this.isShutdown=!0)}destroy(t){this.shutdown(t)}onEnvDestroy(){this.destroy(!0)}onParentDestroy(t,e){this.destroy(e)}setParent(t){var e;return this.parent=t,this.scene=null==(e=t)||"object"!=typeof e?null:m(e)?e:e.scene&&m(e.scene)?e.scene:e.parent&&e.parent.scene&&m(e.parent.scene)?e.parent.scene:null,this.game=function(t){return null==t||"object"!=typeof t?null:k(t)?t:k(t.game)?t.game:m(t)?t.sys.game:m(t.scene)?t.scene.sys.game:void 0}(t),this}}Object.assign(x.prototype,g);const f=Phaser.Utils.Objects.GetValue;class _ extends x{constructor(t,e){super(t,e),this._isRunning=!1,this.isPaused=!1,this.tickingState=!1,this.setTickingMode(f(e,"tickingMode",1))}boot(){2!==this.tickingMode||this.tickingState||this.startTicking()}shutdown(t){this.isShutdown||(this.stop(),this.tickingState&&this.stopTicking(),super.shutdown(t))}setTickingMode(t){"string"==typeof t&&(t=S[t]),this.tickingMode=t}startTicking(){this.tickingState=!0}stopTicking(){this.tickingState=!1}get isRunning(){return this._isRunning}set isRunning(t){this._isRunning!==t&&(this._isRunning=t,1===this.tickingMode&&t!=this.tickingState&&(t?this.startTicking():this.stopTicking()))}start(){return this.isPaused=!1,this.isRunning=!0,this}pause(){return this.isRunning&&(this.isPaused=!0,this.isRunning=!1),this}resume(){return this.isPaused&&(this.isPaused=!1,this.isRunning=!0),this}stop(){return this.isPaused=!1,this.isRunning=!1,this}complete(){this.isPaused=!1,this.isRunning=!1,this.emit("complete",this.parent,this)}}const S={no:0,lazy:1,always:2},w=Phaser.Utils.Objects.GetValue;class T extends _{constructor(t,e){super(t,e);var s=this.scene?"update":"step";this.tickEventName=w(e,"tickEventName",s),this.isSceneTicker=!b(this.tickEventName)}startTicking(){super.startTicking(),this.isSceneTicker?this.scene.sys.events.on(this.tickEventName,this.update,this):this.game.events.on(this.tickEventName,this.update,this)}stopTicking(){super.stopTicking(),this.isSceneTicker&&this.scene?this.scene.sys.events.off(this.tickEventName,this.update,this):this.game&&this.game.events.off(this.tickEventName,this.update,this)}}var b=function(t){return"step"===t||"poststep"===t};const P=Phaser.Utils.Objects.GetValue,E=Phaser.Math.Clamp;class D{constructor(t){this.resetFromJSON(t)}resetFromJSON(t){this.state=P(t,"state",R),this.timeScale=P(t,"timeScale",1),this.delay=P(t,"delay",0),this.repeat=P(t,"repeat",0),this.repeatCounter=P(t,"repeatCounter",0),this.repeatDelay=P(t,"repeatDelay",0),this.duration=P(t,"duration",0),this.nowTime=P(t,"nowTime",0),this.justRestart=P(t,"justRestart",!1)}toJSON(){return{state:this.state,timeScale:this.timeScale,delay:this.delay,repeat:this.repeat,repeatCounter:this.repeatCounter,repeatDelay:this.repeatDelay,duration:this.duration,nowTime:this.nowTime,justRestart:this.justRestart}}destroy(){}setTimeScale(t){return this.timeScale=t,this}setDelay(t){return void 0===t&&(t=0),this.delay=t,this}setDuration(t){return this.duration=t,this}setRepeat(t){return this.repeat=t,this}setRepeatInfinity(){return this.repeat=-1,this}setRepeatDelay(t){return this.repeatDelay=t,this}start(){return this.nowTime=this.delay>0?-this.delay:0,this.state=this.nowTime>=0?G:M,this.repeatCounter=0,this}stop(){return this.state=R,this}update(t,e){this.state!==R&&this.state!==A&&0!==e&&0!==this.timeScale&&(this.nowTime+=e*this.timeScale,this.justRestart=!1,this.nowTime>=this.duration?-1===this.repeat||this.repeatCounter<this.repeat?(this.repeatCounter++,this.justRestart=!0,this.nowTime-=this.duration,this.repeatDelay>0&&(this.nowTime-=this.repeatDelay,this.state=V)):(this.nowTime=this.duration,this.state=A):this.nowTime>=0&&(this.state=G))}get t(){var t;switch(this.state){case R:case M:case V:t=0;break;case G:t=this.nowTime/this.duration;break;case A:t=1}return E(t,0,1)}set t(t){(t=E(t,-1,1))<0?(this.state=M,this.nowTime=-this.delay*t):(this.state=G,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++)}setT(t){return this.t=t,this}get isIdle(){return this.state===R}get isDelay(){return this.state===M}get isCountDown(){return this.state===G}get isRunning(){return this.state===M||this.state===G}get isDone(){return this.state===A}get isOddIteration(){return!(1&~this.repeatCounter)}get isEvenIteration(){return!(1&this.repeatCounter)}}const R=0,M=1,G=2,V=3,A=-1;class F extends T{constructor(t,e){super(t,e),this.timer=new D}shutdown(t){this.isShutdown||(super.shutdown(t),this.timer.destroy(),this.timer=void 0)}start(){return this.timer.start(),super.start(),this}stop(){return this.timer.stop(),super.stop(),this}complete(){return this.timer.stop(),super.complete(),this}}const O=Phaser.Utils.Objects.GetValue,L=Phaser.Utils.Objects.GetAdvancedValue,B=Phaser.Tweens.Builders.GetEaseFunction;class j extends F{resetFromJSON(t){return this.timer.resetFromJSON(O(t,"timer")),this.setEnable(O(t,"enable",!0)),this.setTarget(O(t,"target",this.parent)),this.setDelay(L(t,"delay",0)),this.setDuration(L(t,"duration",1e3)),this.setEase(O(t,"ease","Linear")),this.setRepeat(O(t,"repeat",0)),this}setEnable(t){return null==t&&(t=!0),this.enable=t,this}setTarget(t){return void 0===t&&(t=this.parent),this.target=t,this}setDelay(t){return this.delay=t,this}setDuration(t){return this.duration=t,this}setRepeat(t){return this.repeat=t,this}setRepeatDelay(t){return this.repeatDelay=t,this}setEase(t){return void 0===t&&(t="Linear"),this.ease=t,this.easeFn=B(t),this}start(){return this.timer.isRunning||super.start(),this}restart(){return this.timer.stop(),this.start.apply(this,arguments),this}stop(t){return void 0===t&&(t=!1),super.stop(),t&&(this.timer.setT(1),this.updateTarget(this.target,this.timer),this.complete()),this}update(t,e){if(!this.isRunning||!this.enable||this.parent.hasOwnProperty("active")&&!this.parent.active)return this;var s=this.target,i=this.timer;return i.update(t,e),i.isDelay||this.updateTarget(s,i),this.emit("update",s,this),i.isDone&&this.complete(),this}updateTarget(t,e){}}const N=Phaser.Utils.Objects.GetValue,I=Phaser.Math.Linear;class W extends j{constructor(t,e){super(t,e),this.resetFromJSON(),this.boot()}start(t){if(this.timer.isRunning)return this;var e=this.target;this.propertyKey=N(t,"key","value");var s=e[this.propertyKey];return this.fromValue=N(t,"from",s),this.toValue=N(t,"to",s),this.setEase(N(t,"ease",this.ease)),this.setDuration(N(t,"duration",this.duration)),this.setRepeat(N(t,"repeat",0)),this.setDelay(N(t,"delay",0)),this.setRepeatDelay(N(t,"repeatDelay",0)),this.timer.setDuration(this.duration).setRepeat(this.repeat).setDelay(this.delay).setRepeatDelay(this.repeatDelay),e[this.propertyKey]=this.fromValue,super.start(),this}updateTarget(t,e){var s=e.t;s=this.easeFn(s),t[this.propertyKey]=I(this.fromValue,this.toValue,s)}}const $=Phaser.Math.Percent;var z={setEaseValuePropName(t){return this.easeValuePropName=t,this},setEaseValueDuration(t){return this.easeValueDuration=t,this},setEaseValueFunction(t){return this.easeFunction=t,this},stopEaseValue(){return this.easeValueTask&&this.easeValueTask.stop(),this},easeValueTo(t,e,s){return null==t||(void 0!==e&&(t=$(t,e,s)),void 0===this.easeValueTask&&(this.easeValueTask=new W(this,{eventEmitter:null})),this.easeValueTask.restart({key:this.easeValuePropName,to:t,duration:this.easeValueDuration,ease:this.easeFunction})),this},easeValueRepeat(t,e,s,i){return void 0===s&&(s=-1),void 0===i&&(i=0),void 0===this.easeValueTask&&(this.easeValueTask=new W(this,{eventEmitter:null})),this.easeValueTask.restart({key:this.easeValuePropName,from:t,to:e,duration:this.easeValueDuration,ease:this.easeFunction,repeat:s,repeatDelay:i}),this}};const U=Phaser.Utils.Objects.GetValue,q=Phaser.Math.Clamp,H=Phaser.Utils.String.Pad;var K=function(t,e,s){if(null==t)return t;switch(typeof t){case"string":default:return t;case"number":return`#${H(Math.floor(t).toString(16),6,"0",1)}`;case"function":return t(e,s);case"object":return t.hasOwnProperty("r")?t.hasOwnProperty("a")?`rgba(${t.r},${t.g},${t.b},${t.a})`:`rgb(${t.r},${t.g},${t.b})`:t.hasOwnProperty("h")?t.hasOwnProperty("a")?`hsla(${t.h},${t.s},${t.l},${t.a})`:`hsl(${t.h},${t.s},${t.l})`:t}},Y=function(t,e,s,i,r,a,h,n,o,l,u,d){void 0===l&&(l=0),void 0===u&&(u=2*Math.PI),void 0===d&&(d=!1),e.beginPath(),e.ellipse(s,i,r,a,0,l,u,d),null!=h&&(e.fillStyle=h,e.fill()),null!=n&&(e.strokeStyle=n,e.lineWidth=o,e.stroke())};const J=["AliceBlue","AntiqueWhite","Aqua","Aquamarine","Azure","Beige","Bisque","Black","BlanchedAlmond","Blue","BlueViolet","Brown","BurlyWood","CadetBlue","Chartreuse","Chocolate","Coral","CornflowerBlue","Cornsilk","Crimson","Cyan","DarkBlue","DarkCyan","DarkGoldenRod","DarkGray","DarkGrey","DarkGreen","DarkKhaki","DarkMagenta","DarkOliveGreen","DarkOrange","DarkOrchid","DarkRed","DarkSalmon","DarkSeaGreen","DarkSlateBlue","DarkSlateGray","DarkSlateGrey","DarkTurquoise","DarkViolet","DeepPink","DeepSkyBlue","DimGray","DimGrey","DodgerBlue","FireBrick","FloralWhite","ForestGreen","Fuchsia","Gainsboro","GhostWhite","Gold","GoldenRod","Gray","Grey","Green","GreenYellow","HoneyDew","HotPink","IndianRed","Indigo","Ivory","Khaki","Lavender","LavenderBlush","LawnGreen","LemonChiffon","LightBlue","LightCoral","LightCyan","LightGoldenRodYellow","LightGray","LightGrey","LightGreen","LightPink","LightSalmon","LightSeaGreen","LightSkyBlue","LightSlateGray","LightSlateGrey","LightSteelBlue","LightYellow","Lime","LimeGreen","Linen","Magenta","Maroon","MediumAquaMarine","MediumBlue","MediumOrchid","MediumPurple","MediumSeaGreen","MediumSlateBlue","MediumSpringGreen","MediumTurquoise","MediumVioletRed","MidnightBlue","MintCream","MistyRose","Moccasin","NavajoWhite","Navy","OldLace","Olive","OliveDrab","Orange","OrangeRed","Orchid","PaleGoldenRod","PaleGreen","PaleTurquoise","PaleVioletRed","PapayaWhip","PeachPuff","Peru","Pink","Plum","PowderBlue","Purple","RebeccaPurple","Red","RosyBrown","RoyalBlue","SaddleBrown","Salmon","SandyBrown","SeaGreen","SeaShell","Sienna","Silver","SkyBlue","SlateBlue","SlateGray","SlateGrey","Snow","SpringGreen","SteelBlue","Tan","Teal","Thistle","Tomato","Turquoise","Violet","Wheat","White","WhiteSmoke","Yellow","YellowGreen"],X=[15792383,16444375,65535,8388564,15794175,16119260,16770244,0,16772045,255,9055202,10824234,14596231,6266528,8388352,13789470,16744272,6591981,16775388,14423100,65535,139,35723,12092939,11119017,11119017,25600,12433259,9109643,5597999,16747520,10040012,9109504,15308410,9419919,4734347,3100495,3100495,52945,9699539,16716947,49151,6908265,6908265,2003199,11674146,16775920,2263842,16711935,14474460,16316671,16766720,14329120,8421504,8421504,32768,11403055,15794160,16738740,13458524,4915330,16777200,15787660,15132410,16773365,8190976,16775885,11393254,15761536,14745599,16448210,13882323,13882323,9498256,16758465,16752762,2142890,8900346,7833753,7833753,11584734,16777184,65280,3329330,16445670,16711935,8388608,6737322,205,12211667,9662683,3978097,8087790,64154,4772300,13047173,1644912,16121850,16770273,16770229,16768685,128,16643558,8421376,7048739,16753920,16729344,14315734,15657130,10025880,11529966,14381203,16773077,16767673,13468991,16761035,14524637,11591910,8388736,6697881,16711680,12357519,4286945,9127187,16416882,16032864,3050327,16774638,10506797,12632256,8900331,6970061,7372944,7372944,16775930,65407,4620980,13808780,32896,14204888,16737095,4251856,15631086,16113331,16777215,16119285,16776960,10145074];for(var Q,Z={},tt=0,et=J.length;tt<et;tt++)Q=J[tt].toLowerCase(),Z[Q]=X[tt];var st=function(t){return"string"!=typeof t||(t.startsWith("#")?t=parseInt(t.substring(1),16):t.startsWith("0x")?t=parseInt(t.substring(2),16):(e=(e=t).toLowerCase(),t=Z.hasOwnProperty(e)?Z[e]:null)),t;var e},it=function(t,e){return void 0===e&&(e={}),e.r=t>>16&255,e.g=t>>8&255,e.b=255&t,e};const rt=Phaser.Math.DegToRad,at=Phaser.Math.Linear;var ht,nt;const ot=2*Math.PI;var lt=function(){var t,e,s=this.radius,i=this.thickness*this.radius,r=this.radius-i/2,a=this.radius-i,h=(this.canvas,this.context),n=this.anticlockwise,o=this.startAngle,l=this.endAngle,u=this._deltaAngle;this.trackColor&&i>0&&(h.save(),Y(0,h,s,s,r,r,void 0,this.trackColor,i,o,l,n),h.restore()),this.barColor&&r>0&&(t=this.value>=1?l:n?(o-u*this.value+ot)%ot:(o+u*this.value)%ot,h.save(),this.barColor2?function(t,e,s,i,r,a,h,n,o,l,u,d,c){void 0===l&&(l=0),void 0===u&&(u=2*Math.PI),void 0===d&&(d=!1),void 0===c&&(c=2),h=st(h),n=st(n),ht=it(h,ht),nt=it(n,nt);var v,g=rt(c);(v=d?l-u:u-l)<0&&(v+=2*Math.PI);var p=Math.ceil(v/g),m=v/p;d&&(m=-m);for(var y=0;y<p;y++){var k=y/p,C=Math.round(at(ht.r,nt.r,k)),x=Math.round(at(ht.g,nt.g,k)),f=Math.round(at(ht.b,nt.b,k)),_=l+y*m,S=_+m;y<p-1&&(S+=m/2),e.beginPath(),e.ellipse(s,i,r,a,0,_,S,d),e.strokeStyle=`rgb(${C},${x},${f})`,e.lineWidth=o,e.stroke()}}(0,h,s,s,r,r,this.barColor2,this.barColor,i,o,t,n):Y(0,h,s,s,r,r,void 0,this.barColor,i,o,t,n),h.restore()),this.centerColor&&a>0&&(this.centerColor2?((e=this.context.createRadialGradient(s,s,0,s,s,a)).addColorStop(0,this.centerColor),e.addColorStop(1,this.centerColor2)):e=this.centerColor,h.save(),Y(0,h,s,s,a,a,e),h.restore()),this.textFormatCallback&&(this.textColor||this.textStrokeColor)&&(h.save(),function(t,e,s,i,r,a,h,n,o,l,u){void 0===o&&null!=n&&(o=2),void 0===l&&(l="start"),void 0===u&&(u="alphabetic"),e.font=a,e.textAlign=l,e.textBaseline=u,e.fillStyle=h,e.strokeStyle=n,e.lineWidth=o,e.lineCap="round",e.lineJoin="round",null!=n&&"none"!==n&&o>0&&e.strokeText(r,s,i),null!=h&&"none"!==h&&e.fillText(r,s,i)}(0,h,s,s,this.getFormatText(),this.textFont,this.textColor,this.textStrokeColor,this.textStrokeThickness,"center","middle"),h.restore())};const ut=Phaser.Utils.Objects.GetValue,dt=Phaser.Utils.Objects.IsPlainObject,ct=Phaser.Math.Clamp,vt=Phaser.Math.DegToRad(270),gt=2*Math.PI;class pt extends(function(t){class e extends t{bootProgressBase(t){this.eventEmitter=U(t,"eventEmitter",this);var e=U(t,"valuechangeCallback",null);if(null!==e){var s=U(t,"valuechangeCallbackScope",void 0);this.eventEmitter.on("valuechange",e,s)}return this.setEaseValuePropName("value").setEaseValueDuration(U(t,"easeValue.duration",0)).setEaseValueFunction(U(t,"easeValue.ease","Linear")),this}get value(){return this._value}set value(t){t=q(t,0,1);var e=this._value,s=e!=t;this.dirty=this.dirty||s,this._value=t,s&&this.eventEmitter.emit("valuechange",this._value,e,this.eventEmitter)}}return Object.assign(e.prototype,v,z),e}(l)){constructor(t,e,s,i,r,a,h){dt(e)&&(e=ut(h=e,"x",0),s=ut(h,"y",0),i=ut(h,"radius",1),r=ut(h,"barColor",void 0),a=ut(h,"value",0));var n=2*i;super(t,e,s,n,n,ut(h,"resolution",1)),this.type="rexCircularProgressCanvas",this.bootProgressBase(h),this.setRadius(i),this.setTrackColor(ut(h,"trackColor",void 0)),this.setBarColor(r),this.setBarColor2(ut(h,"barColor2",void 0)),this.setCenterColor(ut(h,"centerColor",void 0)),this.setThickness(ut(h,"thickness",.2)),this.setAnticlockwise(ut(h,"anticlockwise",!1)),this.setStartAngle(ut(h,"startAngle",vt));var o=ut(h,"endAngle");void 0===o&&(o=this.anticlockwise?this.startAngle-gt:this.startAngle+gt),this.setEndAngle(ut(h,"endAngle",o)),this.setTextColor(ut(h,"textColor",void 0)),this.setTextStrokeColor(ut(h,"textStrokeColor",void 0),ut(h,"textStrokeThickness",void 0));var l=ut(h,"textFont",void 0);l?this.setTextFont(l):this.setTextFont(ut(h,"textSize","16px"),ut(h,"textFamily","Courier"),ut(h,"textStyle","")),this.setTextFormatCallback(ut(h,"textFormatCallback",void 0),ut(h,"textFormatCallbackScope",void 0)),this.setValue(a)}resize(t,e){return(t=Math.floor(Math.min(t,e)))===this.width||(super.resize(t,t),this.setRadius(t/2)),this}get radius(){return this._radius}set radius(t){this.dirty=this.dirty||this._radius!=t,this._radius=t;var e=2*t;this.resize(e,e)}setRadius(t){return this.radius=t,this}get trackColor(){return this._trackColor}set trackColor(t){t=K(t,this.canvas,this.context),this.dirty=this.dirty||this._trackColor!=t,this._trackColor=t}setTrackColor(t){return this.trackColor=t,this}get barColor(){return this._barColor}set barColor(t){t=K(t,this.canvas,this.context),this.dirty=this.dirty||this._barColor!=t,this._barColor=t}setBarColor(t){return this.barColor=t,this}get barColor2(){return this._barColor2}set barColor2(t){t=K(t,this.canvas,this.context),this.dirty=this.dirty||this._barColor2!=t,this._barColor2=t}setBarColor2(t){return this.barColor2=t,this}get startAngle(){return this._startAngle}set startAngle(t){this.dirty=this.dirty||this._startAngle!=t,this._startAngle=t,this._deltaAngle=mt(this._startAngle,this._endAngle,this._anticlockwise)}setStartAngle(t){return this.startAngle=t,this}get endAngle(){return this._endAngle}set endAngle(t){this.dirty=this.dirty||this._endAngle!=t,this._endAngle=t,this._deltaAngle=mt(this._startAngle,this._endAngle,this._anticlockwise)}setEndAngle(t){return this.endAngle=t,this}get anticlockwise(){return this._anticlockwise}set anticlockwise(t){this.dirty=this.dirty||this._anticlockwise!=t,this._anticlockwise=t,this._deltaAngle=mt(this._startAngle,this._endAngle,this._anticlockwise)}setAnticlockwise(t){return void 0===t&&(t=!0),this.anticlockwise=t,this}get thickness(){return this._thickness}set thickness(t){t=ct(t,0,1),this.dirty=this.dirty||this._thickness!=t,this._thickness=t}setThickness(t){return this.thickness=t,this}get centerColor(){return this._centerColor}set centerColor(t){t=K(t,this.canvas,this.context),this.dirty=this.dirty||this._centerColor!=t,this._centerColor=t}get centerColor2(){return this._centerColor2}set centerColor2(t){t=K(t,this.canvas,this.context),this.dirty=this.dirty||this._centerColor2!=t,this._centerColor2=t}setCenterColor(t,e){return this.centerColor=t,this.centerColor2=e,this}get textColor(){return this._textColor}set textColor(t){t=K(t,this.canvas,this.context),this.dirty=this.dirty||this._textColor!=t,this._textColor=t}setTextColor(t){return this.textColor=t,this}get textStrokeColor(){return this._textStrokeColor}set textStrokeColor(t){t=K(t,this.canvas,this.context),this.dirty=this.dirty||this._textStrokeColor!=t,this._textStrokeColor=t}get textStrokeThickness(){return this._textStrokeThickness}set textStrokeThickness(t){this.dirty=this.dirty||this._textStrokeThickness!=t,this._textStrokeThickness=t}setTextStrokeColor(t,e){return void 0===e&&(e=2),this.textStrokeColor=t,this.textStrokeThickness=e,this}get textFont(){return this._textFont}set textFont(t){this.dirty=this.dirty||this._textFont!=t,this._textFont=t}setTextFont(t,e,s){var i;return i=void 0===e?t:s+" "+t+" "+e,this.textFont=i,this}setTextFormatCallback(t,e){return this.textFormatCallback=t,this.textFormatCallbackScope=e,this}updateTexture(){return super.updateTexture((function(){this.clear(),lt.call(this)}),this),this}getFormatText(t){return void 0===t&&(t=this.value),this.textFormatCallbackScope?this.textFormatCallback(t):this.textFormatCallback.call(this.textFormatCallbackScope,t)}}var mt=function(t,e,s){return s?t<=e?gt+t-e:t-e:t>=e?gt+e-t:e-t};function yt(t,e,s,i,r,a){var h=new pt(this.scene,t,e,s,i,r,a);return this.scene.add.existing(h),h}const kt=Phaser.GameObjects.BuildGameObject;function Ct(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var s=new pt(this.scene,t);return kt(this.scene,s,t),s}var xt=function(t){return null==t||""===t||0===t.length};class ft extends Phaser.Plugins.BasePlugin{constructor(t){super(t),t.registerGameObject("rexCircularProgressCanvas",yt,Ct)}start(){this.game.events.on("destroy",this.destroy,this)}}return function(t,e,s,i){if(void 0===i&&(i="."),"object"==typeof t)if(xt(e)){if(null==s)return;"object"==typeof s&&(t=s)}else{"string"==typeof e&&(e=e.split(i));var r=e.pop(),a=function(t,e,s){var i=t;if(xt(e));else{var r;"string"==typeof e&&(e=e.split("."));for(var a=0,h=e.length;a<h;a++){var n;null!=i[r=e[a]]&&"object"==typeof i[r]||(n=a===h-1?void 0===s?{}:s:{},i[r]=n),i=i[r]}}return i}(t,e);a[r]=s}}(window,"RexPlugins.GameObjects.CircularProgressCanvas",pt),ft},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexcircularprogresscanvasplugin=e();