phaser3-rex-plugins
Version:
2 lines (1 loc) • 29.2 kB
JavaScript
!function(t,e){"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();}(undefined,(function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var i=0;i<e.length;i++){var s=e[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,(n=s.key,r=void 0,"symbol"==typeof(r=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===e?String:Number)(t)}(n,"string"))?r:String(r)),s);}var n,r;}function s(t,e,s){return e&&i(t.prototype,e),s&&i(t,s),Object.defineProperty(t,"prototype",{writable:!1}),t}function n(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}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e);}function r(t){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},r(t)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function o(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function h(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return !1}}();return function(){var i,s=r(t);if(e){var n=r(this).constructor;i=Reflect.construct(s,arguments,n);}else i=s.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return o(t)}(this,i)}}function u(){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var s=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=r(t)););return t}(t,e);if(s){var n=Object.getOwnPropertyDescriptor(s,e);return n.get?n.get.call(arguments.length<3?t:i):n.value}},u.apply(this,arguments)}var c,l=Phaser.Renderer.WebGL.Utils,v={renderWebGL:function(t,e,i,s){if(e.dirty&&(e.updateTexture(),e.dirty=!1),0!==e.width&&0!==e.height){i.addToRenderList(e);var n=e.frame,r=n.width,a=n.height,o=l.getTintAppendFloatAlpha,h=t.pipelines.set(e.pipeline,e),u=h.setTexture2D(n.glTexture,e);t.pipelines.preBatch(e),h.batchTexture(e,n.glTexture,r,a,e.x,e.y,r/e.resolution,a/e.resolution,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,r,a,o(e.tintTopLeft,i.alpha*e._alphaTL),o(e.tintTopRight,i.alpha*e._alphaTR),o(e.tintBottomLeft,i.alpha*e._alphaBL),o(e.tintBottomRight,i.alpha*e._alphaBR),e.tintFill,0,0,i,s,!1,u),t.pipelines.postBatch(e);}},renderCanvas:function(t,e,i,s){e.dirty&&(e.updateTexture(),e.dirty=!1),0!==e.width&&0!==e.height&&(i.addToRenderList(e),t.batchSprite(e,e.frame,i,s));}},d=Phaser.Display.Color,f={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},drawFrame:function(t,e,i,s,n,r,a,o,h,u){var c=this.scene.sys.textures.getFrame(t,e);if(!c)return this;var l=c.cutWidth,v=c.cutHeight;void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=l),void 0===r&&(r=v),void 0===a&&(a=0),void 0===o&&(o=0),void 0===h&&(h=l),void 0===u&&(u=v);var d=c.cutX+a,f=c.cutY+o;return this.context.drawImage(c.source.image,d,f,h,u,i,s,n,r),this.dirty=!0,this},getDataURL:function(t,e){return this.canvas.toDataURL(t,e)},getPixel:function(t,e,i){void 0===i&&(i=new d);var s=this.context.getImageData(t,e,1,1);return i.setTo(s.data[0],s.data[1],s.data[2],s.data[3]),i},setPixel:function(t,e,i,s,n,r){if("number"!=typeof i){var a=i;i=a.red,s=a.green,n=a.blue,r=a.alpha;}void 0===r&&(r=0!==i||0!==s||0!==n?255:0);var o=this.context.createImageData(1,1);return o.data[0]=i,o.data[1]=s,o.data[2]=n,o.data[3]=r,this.context.putImageData(o,t,e),this.dirty=!0,this}},y={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&&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,s,n){var r=this.canvas;return void 0===s?s=r.width:s*=this.resolution,void 0===n?n=r.height:n*=this.resolution,function(t,e,i,s,n,r,a){var o,h=t.sys.textures,u=t.renderer;void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=e.width),void 0===a&&(a=e.height);var c=(o=h.exists(i)?h.get(i):h.createCanvas(i,r,a)).getSourceImage();c.width!==r&&(c.width=r),c.height!==a&&(c.height=a);var l=c.getContext("2d",{willReadFrequently:!0});l.clearRect(0,0,r,a),l.drawImage(e,s,n,r,a),u.gl&&o&&u.canvasToTexture(c,o.source[0].glTexture,!0,0);}(this.scene,r,t,e,i,s,n),this},loadTexture:function(t,e){var i=this.scene.sys.textures.getFrame(t,e);return i?(this.width!==i.cutWidth||this.height!==i.cutHeight?this.setSize(i.cutWidth,i.cutHeight):this.clear(),this.drawFrame(t,e),this.dirty=!0,this):this}},p=!1;p||(void 0===c&&(c=60),parseInt(Phaser.VERSION.match(/\.(\d+)\./)[1])<c&&console.error("Minimum supported version : 3.".concat(c)),p=!0);var m=Phaser.Display.Canvas.CanvasPool,g=function(t){n(r,t);var i=h(r);function r(t,s,n,a,h){var u;return e(this,r),void 0===s&&(s=0),void 0===n&&(n=0),void 0===a&&(a=1),void 0===h&&(h=1),(u=i.call(this,t,"rexCanvas")).renderer=t.sys.game.renderer,u.resolution=1,u._width=a,u._height=h,a=Math.max(Math.ceil(a*u.resolution),1),h=Math.max(Math.ceil(h*u.resolution),1),u.canvas=m.create(o(u),a,h),u.context=u.canvas.getContext("2d",{willReadFrequently:!0}),u.dirty=!1,u.setPosition(s,n),u.setOrigin(.5,.5),u.initPipeline(),u.initPostPipeline(!0),u._crop=u.resetCropObject(),u.texture=t.sys.textures.addCanvas(null,u.canvas,!0),u.frame=u.texture.get(),u.frame.source.resolution=u.resolution,u.renderer&&u.renderer.gl&&(u.renderer.deleteTexture(u.frame.source.glTexture),u.frame.source.glTexture=null),u.dirty=!0,u}return s(r,[{key:"preDestroy",value:function(){m.remove(this.canvas),this.texture.destroy(),this.canvas=null,this.context=null;}},{key:"width",get:function(){return this._width},set:function(t){this.setSize(t,this._height);}},{key:"height",get:function(){return this._height},set:function(t){this.setSize(this._width,t);}},{key:"setCanvasSize",value:function(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.dirty=!0),this}},{key:"setSize",value:function(t,e){return this.setCanvasSize(t,e),this}},{key:"displayWidth",get:function(){return this.scaleX*this._width},set:function(t){this.scaleX=t/this._width;}},{key:"displayHeight",get:function(){return this.scaleY*this._height},set:function(t){this.scaleY=t/this._height;}},{key:"setDisplaySize",value:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}},{key:"getCanvas",value:function(t){return t||(this.dirty=!0),this.canvas}},{key:"getContext",value:function(t){return t||(this.dirty=!0),this.context}},{key:"needRedraw",value:function(){return this.dirty=!0,this}},{key:"resize",value:function(t,e){return this.setSize(t,e),this}}]),r}(Phaser.GameObjects.GameObject),k=Phaser.GameObjects.Components;Phaser.Class.mixin(g,[k.Alpha,k.BlendMode,k.Crop,k.Depth,k.Flip,k.GetBounds,k.Mask,k.Origin,k.Pipeline,k.PostPipeline,k.ScrollFactor,k.Tint,k.Transform,k.Visible,v,f,y]);var x=Phaser.Math.Linear,b=Phaser.Math.Percent,C={setValue:function(t,e,i){return null==t||(void 0!==e&&(t=b(t,e,i)),this.value=t),this},addValue:function(t,e,i){return void 0!==e&&(t=b(t,e,i)),this.value+=t,this},getValue:function(t,e){var i=this.value;return void 0!==t&&(i=x(t,e,i)),i}},T={setEventEmitter:function(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:function(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter:function(){return this._eventEmitter},on:function(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once:function(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off:function(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit:function(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener:function(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener:function(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners:function(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount:function(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners:function(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames:function(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}},_=Phaser.Scene,w=function(t){return t instanceof _},E=Phaser.Game,P=function(t){return t instanceof E},S=Phaser.Utils.Objects.GetValue,R=function(){function i(t,s){e(this,i),this.setParent(t),this.isShutdown=!1,this.setEventEmitter(S(s,"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));}return s(i,[{key:"shutdown",value:function(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);}},{key:"destroy",value:function(t){this.shutdown(t);}},{key:"onEnvDestroy",value:function(){this.destroy(!0);}},{key:"onParentDestroy",value:function(t,e){this.destroy(e);}},{key:"setParent",value:function(e){var i;return this.parent=e,this.scene=null==(i=e)||"object"!==t(i)?null:w(i)?i:i.scene&&w(i.scene)?i.scene:i.parent&&i.parent.scene&&w(i.parent.scene)?i.parent.scene:null,this.game=function(e){return null==e||"object"!==t(e)?null:P(e)?e:P(e.game)?e.game:w(e)?e.sys.game:w(e.scene)?e.scene.sys.game:void 0}(e),this}}]),i}();Object.assign(R.prototype,T);var O=Phaser.Utils.Objects.GetValue,D=function(t){n(a,t);var i=h(a);function a(t,s){var n;return e(this,a),(n=i.call(this,t,s))._isRunning=!1,n.isPaused=!1,n.tickingState=!1,n.setTickingMode(O(s,"tickingMode",1)),n}return s(a,[{key:"boot",value:function(){2!==this.tickingMode||this.tickingState||this.startTicking();}},{key:"shutdown",value:function(t){this.isShutdown||(this.stop(),this.tickingState&&this.stopTicking(),u(r(a.prototype),"shutdown",this).call(this,t));}},{key:"setTickingMode",value:function(t){"string"==typeof t&&(t=j[t]),this.tickingMode=t;}},{key:"startTicking",value:function(){this.tickingState=!0;}},{key:"stopTicking",value:function(){this.tickingState=!1;}},{key:"isRunning",get:function(){return this._isRunning},set:function(t){this._isRunning!==t&&(this._isRunning=t,1===this.tickingMode&&t!=this.tickingState&&(t?this.startTicking():this.stopTicking()));}},{key:"start",value:function(){return this.isPaused=!1,this.isRunning=!0,this}},{key:"pause",value:function(){return this.isRunning&&(this.isPaused=!0,this.isRunning=!1),this}},{key:"resume",value:function(){return this.isPaused&&(this.isRunning=!0),this}},{key:"stop",value:function(){return this.isPaused=!1,this.isRunning=!1,this}},{key:"complete",value:function(){this.isPaused=!1,this.isRunning=!1,this.emit("complete",this.parent,this);}}]),a}(R),j={no:0,lazy:1,always:2},F=Phaser.Utils.Objects.GetValue,V=function(t){n(a,t);var i=h(a);function a(t,s){var n;e(this,a);var r=(n=i.call(this,t,s)).scene?"update":"step";return n.tickEventName=F(s,"tickEventName",r),n.isSceneTicker=!M(n.tickEventName),n}return s(a,[{key:"startTicking",value:function(){u(r(a.prototype),"startTicking",this).call(this),this.isSceneTicker?this.scene.sys.events.on(this.tickEventName,this.update,this):this.game.events.on(this.tickEventName,this.update,this);}},{key:"stopTicking",value:function(){u(r(a.prototype),"stopTicking",this).call(this),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);}}]),a}(D),M=function(t){return "step"===t||"poststep"===t},G=Phaser.Utils.Objects.GetValue,N=Phaser.Math.Clamp,A=function(){function t(i){e(this,t),this.resetFromJSON(i);}return s(t,[{key:"resetFromJSON",value:function(t){this.state=G(t,"state",L),this.timeScale=G(t,"timeScale",1),this.delay=G(t,"delay",0),this.repeat=G(t,"repeat",0),this.repeatCounter=G(t,"repeatCounter",0),this.repeatDelay=G(t,"repeatDelay",0),this.duration=G(t,"duration",0),this.nowTime=G(t,"nowTime",0),this.justRestart=G(t,"justRestart",!1);}},{key:"toJSON",value:function(){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}}},{key:"destroy",value:function(){}},{key:"setTimeScale",value:function(t){return this.timeScale=t,this}},{key:"setDelay",value:function(t){return void 0===t&&(t=0),this.delay=t,this}},{key:"setDuration",value:function(t){return this.duration=t,this}},{key:"setRepeat",value:function(t){return this.repeat=t,this}},{key:"setRepeatInfinity",value:function(){return this.repeat=-1,this}},{key:"setRepeatDelay",value:function(t){return this.repeatDelay=t,this}},{key:"start",value:function(){return this.nowTime=this.delay>0?-this.delay:0,this.state=this.nowTime>=0?z:B,this.repeatCounter=0,this}},{key:"stop",value:function(){return this.state=L,this}},{key:"update",value:function(t,e){this.state!==L&&this.state!==U&&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=I)):(this.nowTime=this.duration,this.state=U):this.nowTime>=0&&(this.state=z));}},{key:"t",get:function(){var t;switch(this.state){case L:case B:case I:t=0;break;case z:t=this.nowTime/this.duration;break;case U:t=1;}return N(t,0,1)},set:function(t){(t=N(t,-1,1))<0?(this.state=B,this.nowTime=-this.delay*t):(this.state=z,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++);}},{key:"setT",value:function(t){return this.t=t,this}},{key:"isIdle",get:function(){return this.state===L}},{key:"isDelay",get:function(){return this.state===B}},{key:"isCountDown",get:function(){return this.state===z}},{key:"isRunning",get:function(){return this.state===B||this.state===z}},{key:"isDone",get:function(){return this.state===U}},{key:"isOddIteration",get:function(){return 1==(1&this.repeatCounter)}},{key:"isEvenIteration",get:function(){return 0==(1&this.repeatCounter)}}]),t}(),L=0,B=1,z=2,I=3,U=-1,W=function(t){n(a,t);var i=h(a);function a(t,s){var n;return e(this,a),(n=i.call(this,t,s)).timer=new A,n}return s(a,[{key:"shutdown",value:function(t){this.isShutdown||(u(r(a.prototype),"shutdown",this).call(this,t),this.timer.destroy(),this.timer=void 0);}},{key:"start",value:function(){return this.timer.start(),u(r(a.prototype),"start",this).call(this),this}},{key:"stop",value:function(){return this.timer.stop(),u(r(a.prototype),"stop",this).call(this),this}},{key:"complete",value:function(){return this.timer.stop(),u(r(a.prototype),"complete",this).call(this),this}}]),a}(V),J=Phaser.Utils.Objects.GetValue,X=Phaser.Utils.Objects.GetAdvancedValue,Y=Phaser.Tweens.Builders.GetEaseFunction,H=function(t){n(a,t);var i=h(a);function a(){return e(this,a),i.apply(this,arguments)}return s(a,[{key:"resetFromJSON",value:function(t){return this.timer.resetFromJSON(J(t,"timer")),this.setEnable(J(t,"enable",!0)),this.setTarget(J(t,"target",this.parent)),this.setDelay(X(t,"delay",0)),this.setDuration(X(t,"duration",1e3)),this.setEase(J(t,"ease","Linear")),this.setRepeat(J(t,"repeat",0)),this}},{key:"setEnable",value:function(t){return null==t&&(t=!0),this.enable=t,this}},{key:"setTarget",value:function(t){return void 0===t&&(t=this.parent),this.target=t,this}},{key:"setDelay",value:function(t){return this.delay=t,this}},{key:"setDuration",value:function(t){return this.duration=t,this}},{key:"setRepeat",value:function(t){return this.repeat=t,this}},{key:"setRepeatDelay",value:function(t){return this.repeatDelay=t,this}},{key:"setEase",value:function(t){return void 0===t&&(t="Linear"),this.ease=t,this.easeFn=Y(t),this}},{key:"start",value:function(){return this.timer.isRunning||u(r(a.prototype),"start",this).call(this),this}},{key:"restart",value:function(){return this.timer.stop(),this.start.apply(this,arguments),this}},{key:"stop",value:function(t){return void 0===t&&(t=!1),u(r(a.prototype),"stop",this).call(this),t&&(this.timer.setT(1),this.updateGameObject(this.target,this.timer),this.complete()),this}},{key:"update",value:function(t,e){if(!this.isRunning||!this.enable||!this.parent.active)return this;var i=this.target,s=this.timer;return s.update(t,e),s.isDelay||this.updateGameObject(i,s),this.emit("update",i,this),s.isDone&&this.complete(),this}},{key:"updateGameObject",value:function(t,e){}}]),a}(W),K=Phaser.Utils.Objects.GetValue,q=Phaser.Math.Linear,Q=function(t){n(a,t);var i=h(a);function a(t,s){var n;return e(this,a),(n=i.call(this,t,s)).resetFromJSON(),n.boot(),n}return s(a,[{key:"start",value:function(t){if(this.timer.isRunning)return this;var e=this.target;this.propertyKey=K(t,"key","value");var i=e[this.propertyKey];return this.fromValue=K(t,"from",i),this.toValue=K(t,"to",i),this.setEase(K(t,"ease",this.ease)),this.setDuration(K(t,"duration",this.duration)),this.setRepeat(K(t,"repeat",0)),this.setDelay(K(t,"delay",0)),this.setRepeatDelay(K(t,"repeatDelay",0)),this.timer.setDuration(this.duration).setRepeat(this.repeat).setDelay(this.delay).setRepeatDelay(this.repeatDelay),e[this.propertyKey]=this.fromValue,u(r(a.prototype),"start",this).call(this),this}},{key:"updateGameObject",value:function(t,e){var i=e.t;i=this.easeFn(i),t[this.propertyKey]=q(this.fromValue,this.toValue,i);}}]),a}(H),Z=Phaser.Math.Percent,$={setEaseValuePropName:function(t){return this.easeValuePropName=t,this},setEaseValueDuration:function(t){return this.easeValueDuration=t,this},setEaseValueFunction:function(t){return this.easeFunction=t,this},stopEaseValue:function(){return this.easeValueTask&&this.easeValueTask.stop(),this},easeValueTo:function(t,e,i){return null==t||(void 0!==e&&(t=Z(t,e,i)),void 0===this.easeValueTask&&(this.easeValueTask=new Q(this,{eventEmitter:null})),this.easeValueTask.restart({key:this.easeValuePropName,to:t,duration:this.easeValueDuration,ease:this.easeFunction})),this},easeValueRepeat:function(t,e,i,s){return void 0===i&&(i=-1),void 0===s&&(s=0),void 0===this.easeValueTask&&(this.easeValueTask=new Q(this,{eventEmitter:null})),this.easeValueTask.restart({key:this.easeValuePropName,from:t,to:e,duration:this.easeValueDuration,ease:this.easeFunction,repeat:i,repeatDelay:s}),this}},tt=Phaser.Utils.Objects.GetValue,et=Phaser.Math.Clamp;var it=Phaser.Utils.String.Pad,st=function(e,i,s){if(null==e)return e;switch(t(e)){case"string":default:return e;case"number":return "#".concat(it(Math.floor(e).toString(16),6,"0",1));case"function":return e(i,s);case"object":return e.hasOwnProperty("r")?e.hasOwnProperty("a")?"rgba(".concat(e.r,",").concat(e.g,",").concat(e.b,",").concat(e.a,")"):"rgb(".concat(e.r,",").concat(e.g,",").concat(e.b,")"):e.hasOwnProperty("h")?e.hasOwnProperty("a")?"hsla(".concat(e.h,",").concat(e.s,",").concat(e.l,",").concat(e.a,")"):"hsl(".concat(e.h,",").concat(e.s,",").concat(e.l,")"):e}},nt=function(t,e,i,s,n,r,a,o,h,u,c,l){void 0===u&&(u=0),void 0===c&&(c=2*Math.PI),void 0===l&&(l=!1),e.beginPath(),e.ellipse(i,s,n,r,0,u,c,l),null!=a&&(e.fillStyle=a,e.fill()),null!=o&&(e.strokeStyle=o,e.lineWidth=h,e.stroke());},rt=function(){var t,e=this.radius,i=this.thickness*this.radius,s=this.radius-i/2,n=this.radius-i,r=(this.canvas,this.context);if(this.trackColor&&i>0&&(r.save(),nt(0,r,e,e,s,s,void 0,this.trackColor,i),r.restore()),this.barColor&&s>0){var a,o,h;if(1===this.value)a=!1,o=0,h=2*Math.PI;else a=this.anticlockwise,o=this.startAngle,h=2*Math.PI*(a?1-this.value:this.value)+o;r.save(),nt(0,r,e,e,s,s,void 0,this.barColor,i,o,h,a),r.restore();}this.centerColor&&n>0&&(this.centerColor2?((t=this.context.createRadialGradient(e,e,0,e,e,n)).addColorStop(0,this.centerColor),t.addColorStop(1,this.centerColor2)):t=this.centerColor,r.save(),nt(0,r,e,e,n,n,t),r.restore());this.textFormatCallback&&(this.textColor||this.textStrokeColor)&&(r.save(),function(t,e,i,s,n,r,a,o,h,u,c){void 0===h&&null!=o&&(h=2),void 0===u&&(u="start"),void 0===c&&(c="alphabetic"),e.font=r,e.textAlign=u,e.textBaseline=c,e.fillStyle=a,e.strokeStyle=o,e.lineWidth=h,e.lineCap="round",e.lineJoin="round",null!=o&&"none"!==o&&h>0&&e.strokeText(n,i,s),null!=a&&"none"!==a&&e.fillText(n,i,s);}(0,r,e,e,this.getFormatText(),this.textFont,this.textColor,this.textStrokeColor,this.textStrokeThickness,"center","middle"),r.restore());},at=Phaser.Utils.Objects.GetValue,ot=Phaser.Utils.Objects.IsPlainObject,ht=Phaser.Math.Clamp,ut=Phaser.Math.DegToRad(270),ct=function(t){n(a,t);var i=h(a);function a(t,s,n,r,o,h,u){var c;e(this,a),ot(s)&&(s=at(u=s,"x",0),n=at(u,"y",0),r=at(u,"radius",1),o=at(u,"barColor",void 0),h=at(u,"value",0));var l=2*r;(c=i.call(this,t,s,n,l,l)).type="rexCircularProgressCanvas",c.bootProgressBase(u),c.setRadius(r),c.setTrackColor(at(u,"trackColor",void 0)),c.setBarColor(o),c.setCenterColor(at(u,"centerColor",void 0)),c.setThickness(at(u,"thickness",.2)),c.setStartAngle(at(u,"startAngle",ut)),c.setAnticlockwise(at(u,"anticlockwise",!1)),c.setTextColor(at(u,"textColor",void 0)),c.setTextStrokeColor(at(u,"textStrokeColor",void 0),at(u,"textStrokeThickness",void 0));var v=at(u,"textFont",void 0);return v?c.setTextFont(v):c.setTextFont(at(u,"textSize","16px"),at(u,"textFamily","Courier"),at(u,"textStyle","")),c.setTextFormatCallback(at(u,"textFormatCallback",void 0),at(u,"textFormatCallbackScope",void 0)),c.setValue(h),c}return s(a,[{key:"resize",value:function(t,e){return (t=Math.floor(Math.min(t,e)))===this.width||(u(r(a.prototype),"resize",this).call(this,t,t),this.setRadius(t/2)),this}},{key:"radius",get:function(){return this._radius},set:function(t){this.dirty=this.dirty||this._radius!=t,this._radius=t;var e=2*t;this.resize(e,e);}},{key:"setRadius",value:function(t){return this.radius=t,this}},{key:"trackColor",get:function(){return this._trackColor},set:function(t){t=st(t,this.canvas,this.context),this.dirty=this.dirty||this._trackColor!=t,this._trackColor=t;}},{key:"setTrackColor",value:function(t){return this.trackColor=t,this}},{key:"barColor",get:function(){return this._barColor},set:function(t){t=st(t,this.canvas,this.context),this.dirty=this.dirty||this._barColor!=t,this._barColor=t;}},{key:"setBarColor",value:function(t){return this.barColor=t,this}},{key:"startAngle",get:function(){return this._startAngle},set:function(t){this.dirty=this.dirty||this._startAngle!=t,this._startAngle=t;}},{key:"setStartAngle",value:function(t){return this.startAngle=t,this}},{key:"anticlockwise",get:function(){return this._anticlockwise},set:function(t){this.dirty=this.dirty||this._anticlockwise!=t,this._anticlockwise=t;}},{key:"setAnticlockwise",value:function(t){return void 0===t&&(t=!0),this.anticlockwise=t,this}},{key:"thickness",get:function(){return this._thickness},set:function(t){t=ht(t,0,1),this.dirty=this.dirty||this._thickness!=t,this._thickness=t;}},{key:"setThickness",value:function(t){return this.thickness=t,this}},{key:"centerColor",get:function(){return this._centerColor},set:function(t){t=st(t,this.canvas,this.context),this.dirty=this.dirty||this._centerColor!=t,this._centerColor=t;}},{key:"centerColor2",get:function(){return this._centerColor2},set:function(t){t=st(t,this.canvas,this.context),this.dirty=this.dirty||this._centerColor2!=t,this._centerColor2=t;}},{key:"setCenterColor",value:function(t,e){return this.centerColor=t,this.centerColor2=e,this}},{key:"textColor",get:function(){return this._textColor},set:function(t){t=st(t,this.canvas,this.context),this.dirty=this.dirty||this._textColor!=t,this._textColor=t;}},{key:"setTextColor",value:function(t){return this.textColor=t,this}},{key:"textStrokeColor",get:function(){return this._textStrokeColor},set:function(t){t=st(t,this.canvas,this.context),this.dirty=this.dirty||this._textStrokeColor!=t,this._textStrokeColor=t;}},{key:"textStrokeThickness",get:function(){return this._textStrokeThickness},set:function(t){this.dirty=this.dirty||this._textStrokeThickness!=t,this._textStrokeThickness=t;}},{key:"setTextStrokeColor",value:function(t,e){return void 0===e&&(e=2),this.textStrokeColor=t,this.textStrokeThickness=e,this}},{key:"textFont",get:function(){return this._textFont},set:function(t){this.dirty=this.dirty||this._textFont!=t,this._textFont=t;}},{key:"setTextFont",value:function(t,e,i){var s;return s=void 0===e?t:i+" "+t+" "+e,this.textFont=s,this}},{key:"setTextFormatCallback",value:function(t,e){return this.textFormatCallback=t,this.textFormatCallbackScope=e,this}},{key:"updateTexture",value:function(){return this.clear(),rt.call(this),u(r(a.prototype),"updateTexture",this).call(this),this}},{key:"getFormatText",value:function(t){return void 0===t&&(t=this.value),this.textFormatCallbackScope?this.textFormatCallback(t):this.textFormatCallback.call(this.textFormatCallbackScope,t)}}]),a}(function(t){var i=function(t){n(r,t);var i=h(r);function r(){return e(this,r),i.apply(this,arguments)}return s(r,[{key:"bootProgressBase",value:function(t){this.eventEmitter=tt(t,"eventEmitter",this);var e=tt(t,"valuechangeCallback",null);if(null!==e){var i=tt(t,"valuechangeCallbackScope",void 0);this.eventEmitter.on("valuechange",e,i);}return this.setEaseValuePropName("value").setEaseValueDuration(tt(t,"easeValue.duration",0)).setEaseValueFunction(tt(t,"easeValue.ease","Linear")),this}},{key:"value",get:function(){return this._value},set:function(t){t=et(t,0,1);var e=this._value,i=e!=t;this.dirty=this.dirty||i,this._value=t,i&&this.eventEmitter.emit("valuechange",this._value,e,this.eventEmitter);}}]),r}(t);return Object.assign(i.prototype,C,$),i}(g));function lt(t,e,i,s,n,r){var a=new ct(this.scene,t,e,i,s,n,r);return this.scene.add.existing(a),a}var vt=Phaser.GameObjects.BuildGameObject;function dt(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=new ct(this.scene,t);return vt(this.scene,i,t),i}var ft=function(t){return null==t||""===t||0===t.length},yt=function(t){n(r,Phaser.Plugins.BasePlugin);var i=h(r);function r(t){var s;return e(this,r),s=i.call(this,t),t.registerGameObject("rexCircularProgressCanvas",lt,dt),s}return s(r,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this);}}]),r}();return function(e,i,s,n){if(void 0===n&&(n="."),"object"===t(e)){if(ft(i)){if(null==s)return;"object"===t(s)&&(e=s);}else {"string"==typeof i&&(i=i.split(n));var r=i.pop(),a=function(e,i,s){var n=e;if(ft(i));else {var r;"string"==typeof i&&(i=i.split("."));for(var a=0,o=i.length;a<o;a++){var h;null!=n[r=i[a]]&&"object"===t(n[r])||(h=a===o-1?void 0===s?{}:s:{},n[r]=h),n=n[r];}}return n}(e,i);a[r]=s;}}}(window,"RexPlugins.GameObjects.CircularProgressCanvas",ct),yt}));