UNPKG

phaser3-rex-plugins

Version:
2 lines (1 loc) 37.4 kB
var t,e;t=void 0,e=function(){const t=Phaser.GameObjects.GetCalcMatrix,e=Phaser.Renderer.Canvas.SetTransform;var i={renderWebGL:function(e,i,s,h){i.updateData(),s.addToRenderList(i);var r=e.pipelines.set(i.pipeline),a=t(i,s,h),n=r.calcMatrix.copyFrom(a.calc),o=i._displayOriginX,l=i._displayOriginY,u=s.alpha*i.alpha;e.pipelines.preBatch(i);for(var d,p=i.geom,c=0,v=p.length;c<v;c++)(d=p[c]).visible&&d.webglRender(r,n,u,o,l);e.pipelines.postBatch(i)},renderCanvas:function(t,i,s,h){i.updateData(),s.addToRenderList(i);var r=t.currentContext;if(e(t,r,i,s,h)){for(var a,n=i._displayOriginX,o=i._displayOriginY,l=i.geom,u=0,d=l.length;u<d;u++)(a=l[u]).visible&&a.canvasRender(r,n,o);r.restore()}}},s=function(t){if("object"!=typeof t||null===t)return t;if(Array.isArray(t))t.length=0;else for(var e in t)delete t[e];return t};const h=Phaser.GameObjects.Shape,r=Phaser.Utils.Array.Remove;class a extends h{constructor(t,e,i,s,h){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=2),void 0===h&&(h=s),super(t,"rexShapes",[]),this._width=-1,this._height=-1,this.dirty=!0,this.isSizeChanged=!0,this.shapes={},this.setPosition(e,i),this.setSize(s,h),this.updateDisplayOrigin()}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)}setDirty(t){return void 0===t&&(t=!0),this.dirty=t,this}setSize(t,e){this.isSizeChanged=this.isSizeChanged||this._width!==t||this._height!==e,this.dirty=this.dirty||this.isSizeChanged,this._width=t,this._height=e,this.updateDisplayOrigin();var i=this.input;return i&&!i.customHitArea&&(i.hitArea.width=t,i.hitArea.height=e),this}resize(t,e){return this.setSize(t,e),this}get fillColor(){return this._fillColor}set fillColor(t){this.setFillStyle(t,this._fillAlpha)}get fillAlpha(){return this._fillAlpha}set fillAlpha(t){this.setFillStyle(this._fillColor,t)}setFillStyle(t,e){return void 0===e&&(e=1),this.dirty=this.dirty||this.fillColor!==t||this.fillAlpha!==e,this._fillColor=t,this._fillAlpha=e,this}get lineWidth(){return this._lineWidth}set lineWidth(t){this.setStrokeStyle(t,this._strokeColor,this._strokeAlpha)}get strokeColor(){return this._strokeColor}set strokeColor(t){this.setStrokeStyle(this._lineWidth,t,this._strokeAlpha)}get strokeAlpha(){return this._strokeAlpha}set strokeAlpha(t){this.setStrokeStyle(this._lineWidth,this._strokeColor,t)}setStrokeStyle(t,e,i){return void 0===i&&(i=1),this.dirty=this.dirty||this.lineWidth!==t||this.strokeColor!==e||this.strokeAlpha!==i,this._lineWidth=t,this._strokeColor=e,this._strokeAlpha=i,this}updateShapes(){}updateData(){if(!this.dirty)return this;this.updateShapes();for(var t=this.geom,e=0,i=t.length;e<i;e++){var s=t[e];s.dirty&&s.updateData()}return this.isSizeChanged=!1,this.dirty=!1,this}clear(){return this.geom.length=0,s(this.shapes),this.dirty=!0,this}getShape(t){return this.shapes[t]}getShapes(){return this.geom}addShape(t){this.geom.push(t);var e=t.name;return e&&(this.shapes[e]=t),this.dirty=!0,this}deleteShape(t){var e=this.getShape(t);return e&&(delete this.shapes[t],r(this.geom,e)),this}}Object.assign(a.prototype,i);const n=Phaser.Math.Linear,o=Phaser.Math.Percent;var l={setValue(t,e,i){return null==t||(void 0!==e&&(t=o(t,e,i)),this.value=t),this},addValue(t,e,i){return void 0!==e&&(t=o(t,e,i)),this.value+=t,this},getValue(t,e){var i=this.value;return void 0!==t&&void 0!==e&&(i=n(t,e,i)),i}},u={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 d=Phaser.Scene;var p=function(t){return t instanceof d};const c=Phaser.Game;var v=function(t){return t instanceof c};const g=Phaser.Utils.Objects.GetValue;class y{constructor(t,e){this.setParent(t),this.isShutdown=!1,this.setEventEmitter(g(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:p(e)?e:e.scene&&p(e.scene)?e.scene:e.parent&&e.parent.scene&&p(e.parent.scene)?e.parent.scene:null,this.game=function(t){return null==t||"object"!=typeof t?null:v(t)?t:v(t.game)?t.game:p(t)?t.sys.game:p(t.scene)?t.scene.sys.game:void 0}(t),this}}Object.assign(y.prototype,u);const f=Phaser.Utils.Objects.GetValue;class m extends y{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=P[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 P={no:0,lazy:1,always:2},D=Phaser.Utils.Objects.GetValue;class k extends m{constructor(t,e){super(t,e);var i=this.scene?"update":"step";this.tickEventName=D(e,"tickEventName",i),this.isSceneTicker=!_(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 _=function(t){return"step"===t||"poststep"===t};const b=Phaser.Utils.Objects.GetValue,S=Phaser.Math.Clamp;class A{constructor(t){this.resetFromJSON(t)}resetFromJSON(t){this.state=b(t,"state",T),this.timeScale=b(t,"timeScale",1),this.delay=b(t,"delay",0),this.repeat=b(t,"repeat",0),this.repeatCounter=b(t,"repeatCounter",0),this.repeatDelay=b(t,"repeatDelay",0),this.duration=b(t,"duration",0),this.nowTime=b(t,"nowTime",0),this.justRestart=b(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?w:C,this.repeatCounter=0,this}stop(){return this.state=T,this}update(t,e){this.state!==T&&this.state!==x&&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=E)):(this.nowTime=this.duration,this.state=x):this.nowTime>=0&&(this.state=w))}get t(){var t;switch(this.state){case T:case C:case E:t=0;break;case w:t=this.nowTime/this.duration;break;case x:t=1}return S(t,0,1)}set t(t){(t=S(t,-1,1))<0?(this.state=C,this.nowTime=-this.delay*t):(this.state=w,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++)}setT(t){return this.t=t,this}get isIdle(){return this.state===T}get isDelay(){return this.state===C}get isCountDown(){return this.state===w}get isRunning(){return this.state===C||this.state===w}get isDone(){return this.state===x}get isOddIteration(){return!(1&~this.repeatCounter)}get isEvenIteration(){return!(1&this.repeatCounter)}}const T=0,C=1,w=2,E=3,x=-1;class R extends k{constructor(t,e){super(t,e),this.timer=new A}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 M=Phaser.Utils.Objects.GetValue,O=Phaser.Utils.Objects.GetAdvancedValue,V=Phaser.Tweens.Builders.GetEaseFunction;class L extends R{resetFromJSON(t){return this.timer.resetFromJSON(M(t,"timer")),this.setEnable(M(t,"enable",!0)),this.setTarget(M(t,"target",this.parent)),this.setDelay(O(t,"delay",0)),this.setDuration(O(t,"duration",1e3)),this.setEase(M(t,"ease","Linear")),this.setRepeat(M(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=V(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 i=this.target,s=this.timer;return s.update(t,e),s.isDelay||this.updateTarget(i,s),this.emit("update",i,this),s.isDone&&this.complete(),this}updateTarget(t,e){}}const F=Phaser.Utils.Objects.GetValue,j=Phaser.Math.Linear;class X extends L{constructor(t,e){super(t,e),this.resetFromJSON(),this.boot()}start(t){if(this.timer.isRunning)return this;var e=this.target;this.propertyKey=F(t,"key","value");var i=e[this.propertyKey];return this.fromValue=F(t,"from",i),this.toValue=F(t,"to",i),this.setEase(F(t,"ease",this.ease)),this.setDuration(F(t,"duration",this.duration)),this.setRepeat(F(t,"repeat",0)),this.setDelay(F(t,"delay",0)),this.setRepeatDelay(F(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 i=e.t;i=this.easeFn(i),t[this.propertyKey]=j(this.fromValue,this.toValue,i)}}const Y=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,i){return null==t||(void 0!==e&&(t=Y(t,e,i)),void 0===this.easeValueTask&&(this.easeValueTask=new X(this,{eventEmitter:null})),this.easeValueTask.restart({key:this.easeValuePropName,to:t,duration:this.easeValueDuration,ease:this.easeFunction})),this},easeValueRepeat(t,e,i,s){return void 0===i&&(i=-1),void 0===s&&(s=0),void 0===this.easeValueTask&&(this.easeValueTask=new X(this,{eventEmitter:null})),this.easeValueTask.restart({key:this.easeValuePropName,from:t,to:e,duration:this.easeValueDuration,ease:this.easeFunction,repeat:i,repeatDelay:s}),this}};const N=Phaser.Utils.Objects.GetValue,G=Phaser.Math.Clamp;var I={fillStyle:function(t,e){return null==t?this.isFilled=!1:(void 0===e&&(e=1),this.isFilled=!0,this.fillColor=t,this.fillAlpha=e),this},lineStyle:function(t,e,i){return null==t||null==e?this.isStroked=!1:(void 0===i&&(i=1),this.isStroked=!0,this.lineWidth=t,this.strokeColor=e,this.strokeAlpha=i),this}},B=function(t,e,i){for(var s=t,h=i,r=0,a=e.length;r<a;r++){var n=e[r];if(!s||"object"!=typeof s&&"function"!=typeof s||!(n in s))return W.found=!1,W;s=h=s[n]}return W.found=!0,W.value=h,W},W={},U={enableData(){return void 0===this.data&&(this.data={}),this},setData(t,e){if(this.enableData(),1===arguments.length){var i=t;for(t in i)this.data[t]=i[t]}else this.data[t]=e;return this},getData(t,e){return this.enableData(),void 0===t?this.data:function(t,e,i,s){var h=t&&("object"==typeof t||"function"==typeof t),r=s&&("object"==typeof s||"function"==typeof s);if(!h&&!r)return i;var a=String(e);if(h&&a in t)return t[a];if(r&&a in s)return s[a];if(-1===a.indexOf("."))return i;var n=a.split(".");if(h){var o=B(t,n,i);if(o.found)return o.value}if(r){var l=B(s,n,i);if(l.found)return l.value}return i}(this.data,t,e)},incData(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)+e),this},mulData(t,e,i){return void 0===i&&(i=0),this.enableData(),this.setData(t,this.getData(t,i)*e),this},clearData(){return this.data&&s(this.data),this}};class J{constructor(){this.name=void 0,this.dirty=!0,this.visible=!0,this.data=void 0,this.isFilled=!1,this.fillColor=void 0,this.fillAlpha=1,this.isStroked=!1,this.lineWidth=1,this.strokeColor=void 0,this.strokeAlpha=1}setName(t){return this.name=t,this}setVisible(t){return void 0===t&&(t=!0),this.visible=t,this}reset(){return this.setVisible().fillStyle().lineStyle(),this}webglRender(t,e,i,s,h){}canvasRender(t,e,i){}updateData(){this.dirty=!1}}Object.assign(J.prototype,I,U);var q=Phaser.Renderer.WebGL.Utils,K=function(t,e,i,s,h,r){for(var a=q.getTintAppendFloatAlpha(i.fillColor,i.fillAlpha*s),n=i.pathData,o=i.pathIndexes,l=0;l<o.length;l+=3){var u=2*o[l],d=2*o[l+1],p=2*o[l+2],c=n[u+0]-h,v=n[u+1]-r,g=n[d+0]-h,y=n[d+1]-r,f=n[p+0]-h,m=n[p+1]-r,P=e.getX(c,v),D=e.getY(c,v),k=e.getX(g,y),_=e.getY(g,y),b=e.getX(f,m),S=e.getY(f,m);t.batchTri(i,P,D,k,_,b,S,0,0,1,1,a,a,a,2)}},H=Phaser.Renderer.WebGL.Utils,Q=function(t,e,i,s,h){var r=t.strokeTint,a=H.getTintAppendFloatAlpha(e.strokeColor,e.strokeAlpha*i);r.TL=a,r.TR=a,r.BL=a,r.BR=a;var n,o,l=e.isDashed&&!!e.strokePathData,u=l?e.strokePathData:e.pathData,d=u.length-1,p=e.lineWidth,c=p/2,v=u[0]-s,g=u[1]-h;if(e.closePath||(d-=2),l){var y=e.strokePathMask,f=0,m=0;for(P=2;P<d;P+=2)n=u[P]-s,o=u[P+1]-h,y[f]?(t.batchLine(v,g,n,o,c,c,p,m,!1),m++):m=0,v=n,g=o,f++}else for(var P=2;P<d;P+=2)n=u[P]-s,o=u[P+1]-h,t.batchLine(v,g,n,o,c,c,p,P-2,!!e.closePath&&P===d-1),v=n,g=o},Z=function(t,e,i,s){var h=i||e.fillColor,r=s||e.fillAlpha,a=(16711680&h)>>>16,n=(65280&h)>>>8,o=255&h;t.fillStyle="rgba("+a+","+n+","+o+","+r+")"},$=function(t,e,i,s){var h=e.pathData;if(h&&!(h.length<4)){var r=h.length-1,a=h[0]-i,n=h[1]-s;t.beginPath(),t.moveTo(a,n),e.closePath||(r-=2);for(var o=2;o<r;o+=2){var l=h[o]-i,u=h[o+1]-s;t.lineTo(l,u)}e.closePath&&t.closePath(),Z(t,e),t.fill()}},tt=function(t,e,i,s){var h=e.isDashed&&!!e.strokePathData,r=h?e.strokePathData:e.pathData;if(r&&!(r.length<4)){var a=r.length-1,n=r[0]-i,o=r[1]-s;if(function(t,e,i,s){var h=i||e.strokeColor,r=s||e.strokeAlpha,a=(16711680&h)>>>16,n=(65280&h)>>>8,o=255&h;t.strokeStyle="rgba("+a+","+n+","+o+","+r+")",t.lineWidth=e.lineWidth}(t,e),t.beginPath(),e.closePath||(a-=2),h){var l=e.strokePathMask,u=0;for(d=2;d<a;d+=2)p=r[d]-i,c=r[d+1]-s,l[u]&&(t.moveTo(n,o),t.lineTo(p,c)),n=p,o=c,u++}else{t.moveTo(n,o);for(var d=2;d<a;d+=2){var p=r[d]-i,c=r[d+1]-s;t.lineTo(p,c)}e.closePath&&t.closePath()}t.stroke()}};const et=1e-6,it=10,st=.5;var ht=function(t,e){return function(t){if(!Array.isArray(t))return null;for(var e=[],i=0,s=t.length;i<s;i++){var h=Number(t[i]);isFinite(h)&&h>0&&e.push(h)}return e.length>0?e:null}(t)||function(t,e){var{segments:i=it,drawRatio:s=st}=t;if(i=Math.round(i),!isFinite(i)||i<=0)return null;if(!(e>et))return null;var h=e/i;if(!(h>et))return null;if((s=Math.max(0,Math.min(1,s)))>=.999999)return null;var r=h*s;r<=et&&(r=et);var a=h-r;return a<=et?null:[r,a]}(t,e)},rt=function(t,e,i){if(t&&!(t.length<4)){var s=t.length-1;if(e||(s-=2),!(s<2))for(var h=t[0],r=t[1],a=2;a<s;a+=2){var n=t[a],o=t[a+1];i(h,r,n,o),h=n,r=o}}},at=function(t,e,i){void 0===e&&(e={}),void 0===i&&(i={});var{closePath:s=!1,dashPattern:h,dashOffset:r=0}=e,a=function(t,e){var i=0;return rt(t,e,(function(t,e,s,h){var r=s-t,a=h-e;i+=Math.sqrt(r*r+a*a)})),i}(t,s);if(null===(h=ht(h,a)))return null;for(var n=[],o=[],l=0,u=0,d=h.length;u<d;u++)l+=h[u];if(l<=et)return i.strokePathData=t?t.slice():[],i.strokePathMask=void 0,i;for(var p=0,c=!0,v=h[p],g=function(){p=(p+1)%h.length,c=!c,v=h[p]},y=function(t,e){return isFinite(t)||(t=0),(t%=e)<0&&(t+=e),t}(r,l);y>et;)y<v-et?(v-=y,y=0):(y-=v,g());var f=function(t,e,i,s,h){if(0===n.length)n.push(t,e);else{var r=n[n.length-2],a=n[n.length-1];r===t&&a===e||n.push(t,e)}n.push(i,s),o.push(h?1:0)};return rt(t,s,(function(t,e,i,s){var h=i-t,r=s-e,a=Math.sqrt(h*h+r*r);if(!(a<=et))for(var n=0;n<a-et;){var o=Math.min(v,a-n);if(o<=et)g();else{var l=n/a,u=(n+o)/a;f(t+h*l,e+r*l,t+h*u,e+r*u,c),n+=o,(v-=o)<=et&&g()}}})),!s&&n.length>=2&&n.push(n[n.length-2],n[n.length-1]),i.strokePathData=n,i.strokePathMask=o,i},nt={setDashPattern:function(t,e){return this.dashPattern=t,this.dashOffset=e||0,this.isDashed=!!t,this},clearDashPattern:function(){return this.setDashPattern(),this},setDashed:function(t){return void 0===t&&(t=!0),this.isDashed=t,this}},ot={buildStrokePath:function(){if(this.isDashed){var t=at(this.pathData,{closePath:this.closePath,dashPattern:this.dashPattern,dashOffset:this.dashOffset},this);t?(this.strokePathData=t.strokePathData,this.strokePathMask=t.strokePathMask):this.isDashed=!1}return this}};Object.assign(ot,nt);const lt=Phaser.Geom.Polygon.Earcut;class ut extends J{constructor(){super(),this.pathData=[],this.isDashed=!1,this.strokePathData=void 0,this.strokePathMask=void 0,this.dashPattern=void 0,this.dashOffset=0,this.pathIndexes=[],this.closePath=!1}updateData(){return this.pathIndexes=lt(this.pathData),super.updateData(),this.buildStrokePath(),this}webglRender(t,e,i,s,h){this.isFilled&&K(t,e,this,i,s,h),this.isStroked&&Q(t,this,i,s,h)}canvasRender(t,e,i){this.isFilled&&$(t,this,e,i),this.isStroked&&tt(t,this,e,i)}}Object.assign(ut.prototype,ot);var dt=function(t,e,i){var s=i.length;if(s>=2){var h=i[s-2],r=i[s-1];if(t===h&&e===r)return i}return i.push(t,e),i};const pt=Phaser.Math.DegToRad;var ct=function(t,e,i,s,h,r,a,n,o){a&&r>h?r-=360:!a&&r<h&&(r+=360);var l=pt(r-h)/n;h=pt(h);for(var u=0;u<=n;u++){var d=h+l*u,p=t+i*Math.cos(d),c=e+s*Math.sin(d);dt(p,c,o)}return o};Phaser.Math.DegToRad;class vt extends ut{constructor(t,e,i,s,h,r,a,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===h&&(h=0),void 0===r&&(r=360),void 0===a&&(a=!1),void 0===n&&(n=!1),super(),this.setCenterPosition(t,e),this.setRadius(i,s),this.setAngle(h,r,a),this.setPie(n),this.setIterations(32)}get x(){return this._x}set x(t){this.dirty=this.dirty||this._x!==t,this._x=t}get y(){return this._y}set y(t){this.dirty=this.dirty||this._y!==t,this._y=t}setCenterPosition(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this}get radiusX(){return this._radiusX}set radiusX(t){this.dirty=this.dirty||this._radiusX!==t,this._radiusX=t}get radiusY(){return this._radiusY}set radiusY(t){this.dirty=this.dirty||this._radiusY!==t,this._radiusY=t}setRadius(t,e){return void 0===e&&(e=t),this.radiusX=t,this.radiusY=e,this}get startAngle(){return this._startAngle}set startAngle(t){this.dirty=this.dirty||this._startAngle!==t,this._startAngle=t}get endAngle(){return this._endAngle}set endAngle(t){this.dirty=this.dirty||this._endAngle!==t,this._endAngle=t}get anticlockwise(){return this._anticlockwise}set anticlockwise(t){this.dirty=this.dirty||this._anticlockwise!==t,this._anticlockwise=t}setAngle(t,e,i){return void 0===i&&(i=!1),this.startAngle=t,this.endAngle=e,this.anticlockwise=i,this}get pie(){return this._pie}set pie(t){this.dirty=this.dirty||this._pie!==t,this._pie=t}setPie(t){return void 0===t&&(t=!0),this.pie=t,this}get iterations(){return this._iterations}set iterations(t){this.dirty=this.dirty||this._iterations!==t,this._iterations=t}setIterations(t){return this.iterations=t,this}updateData(){return this.pathData.length=0,this.pie&&this.pathData.push(this.x,this.y),ct(this.x,this.y,this.radiusX,this.radiusY,this.startAngle,this.endAngle,this.anticlockwise,this.iterations,this.pathData),this.pie&&this.pathData.push(this.x,this.y),this.pathData.push(this.pathData[0],this.pathData[1]),super.updateData(),this}}class gt extends vt{constructor(t,e,i){super(t,e,i,i,0,360)}}const yt=Phaser.Math.Interpolation.QuadraticBezier,ft=Phaser.Math.Interpolation.CubicBezier,mt=Phaser.Math.Interpolation.CatmullRom;var Pt=function(t){var e=t.length;if(e<2)return t;var i=t[e-2],s=t[e-1];return t.push(i),t.push(s),t},Dt={clear(){return this.start(),this},start(){return this.startAt(),this},startAt(t,e){return this.restorePathData(),this.accumulationLengths=void 0,function(t,e,i){i.length=0,null!=t&&i.push(t,e)}(t,e,this.pathData),this.firstPointX=t,this.firstPointY=e,this.lastPointX=t,this.lastPointY=e,this},lineTo(t,e,i){return void 0===i&&(i=!1),i&&(t+=this.lastPointX,e+=this.lastPointY),dt(t,e,this.pathData),this.lastPointX=t,this.lastPointY=e,this},verticalLineTo(t,e){return this.lineTo(t,this.lastPointY,e),this},horizontalLineTo(t,e){return this.lineTo(this.lastPointX,t,e),this},ellipticalArc(t,e,i,s,h,r,a){return void 0===a&&(a=!1),ct(t,e,i,s,h,r,a,this.iterations,this.pathData),this.lastPointX=this.pathData[this.pathData.length-2],this.lastPointY=this.pathData[this.pathData.length-1],this},arc(t,e,i,s,h,r){return this.ellipticalArc(t,e,i,i,s,h,r),this},quadraticBezierTo(t,e,i,s){return function(t,e,i,s,h,r){for(var a=r.length,n=r[a-2],o=r[a-1],l=1,u=h-1;l<=u;l++){var d=l/u;r.push(yt(d,n,t,i),yt(d,o,e,s))}}(t,e,i,s,this.iterations,this.pathData),this.lastPointX=i,this.lastPointY=s,this},cubicBezierTo(t,e,i,s,h,r){return function(t,e,i,s,h,r,a,n){for(var o=n.length,l=n[o-2],u=n[o-1],d=1,p=a-1;d<=p;d++){var c=d/p;n.push(ft(c,l,t,i,h),ft(c,u,e,s,r))}}(t,e,i,s,h,r,this.iterations,this.pathData),this.lastPointX=h,this.lastPointY=r,this},catmullRomTo(...t){return function(t,e,i){for(var s=i.length,h=[i[s-2]],r=[i[s-1]],a=0,n=t.length;a<n;a+=2)h.push(t[a]),r.push(t[a+1]);a=1;for(var o=e-1;a<=o;a++){var l=a/o;i.push(mt(h,l),mt(r,l))}}(t,this.iterations,this.pathData),this.lastPointX=t[t.length-2],this.lastPointY=t[t.length-1],this},close(){var t=this.pathData[0],e=this.pathData[1];return t===this.lastPointX&&e===this.lastPointY||this.lineTo(t,e),this.closePath=!0,this},end(){return Pt(this.pathData),this}};const kt=Phaser.Math.RotateAround,_t=Phaser.Math.DegToRad;Phaser.Math.RotateAround;var bt={rotateAround(t,e,i){if(0===this.pathData.length)return this;!function(t,e,i,s){for(var h={x:0,y:0},r=0,a=s.length-1;r<a;r+=2)h.x=s[r],h.y=s[r+1],kt(h,t,e,i),s[r]=h.x,s[r+1]=h.y}(t,e,i=_t(i),this.pathData);var s=this.pathData.length;return this.lastPointX=this.pathData[s-2],this.lastPointY=this.pathData[s-1],this},scale(t,e,i,s){return 0===this.pathData.length||(function(t,e,i,s,h){for(var r=0,a=h.length-1;r<a;r+=2){var n=h[r]-t,o=h[r+1]-e;n*=i,o*=s,h[r]=n+t,h[r+1]=o+e}}(t,e,i,s,this.pathData),this.lastPointX=this.pathData[pathDataCnt-2],this.lastPointY=this.pathData[pathDataCnt-1]),this},offset(t,e){return function(t,e,i){for(var s=0,h=i.length-1;s<h;s+=2)i[s]+=t,i[s+1]+=e}(t,e,this.pathData),this}},St={savePathData(){return this.pathDataSaved||(this.pathDataSave=[...this.pathData],this.pathData.length=0,this.pathDataSaved=!0),this},restorePathData(){return this.pathDataSaved?(function(t,e,i,s){void 0===i&&(i=0),void 0===s&&(s=e.length),t.length=s-i;for(var h=0,r=t.length;h<r;h++)t[h]=e[h+i]}(this.pathData,this.pathDataSave),this.pathDataSave=void 0,this.pathDataSaved=!1,this):this}};const At=Phaser.Math.Distance.Between,Tt=Phaser.Math.Wrap,Ct=Phaser.Math.Linear;var wt=function(t,e,i,s,h){if(void 0===s&&(s=i,i=0),(i=Rt(i))!==(s=Rt(s))){var r=e[e.length-1],a=r*i,n=r*s;i<s?Et(t,e,a,n,h):(Et(t,e,a,r,h),Et(t,e,0,n,h)),Pt(h)}},Et=function(t,e,i,s,h){for(var r=i>0,a=0,n=e.length;a<n;a++){var o=2*a,l=e[a];if(r){if(l<i)continue;if(l==i)r=!1;else{var u=1-(l-i)/(l-e[a-1]);h.push(xt(t,o-2,o,u)),h.push(xt(t,o-1,o+1,u)),r=!1}}if(!(l<=s)){u=1-(l-s)/(l-e[a-1]),h.push(xt(t,o-2,o,u)),h.push(xt(t,o-1,o+1,u));break}if(h.push(t[o]),h.push(t[o+1]),l===s)break}},xt=function(t,e,i,s){var h=t[e],r=t[i];return Ct(h,r,s)},Rt=function(t){return 0===t?0:t%1==0?1:Tt(t,0,1)},Mt={updateAccumulationLengths(){if(null==this.accumulationLengths)this.accumulationLengths=[];else if(this.accumulationLengths.length===this.pathData.length/2)return this;for(var t,e,i,s,h=this.accumulationLengths,r=this.pathData,a=0,n=0,o=r.length;n<o;n+=2)i=r[n],s=r[n+1],a+=void 0===t?0:At(t,e,i,s),h.push(a),t=i,e=s;return this.totalPathLength=a,this},setDisplayPathSegment(t,e){return this.pathDataSaved||(this.updateAccumulationLengths(),this.savePathData()),this.pathData.length=0,wt(this.pathDataSave,this.accumulationLengths,t,e,this.pathData),this},appendFromPathSegment(t,e,i){return void 0===e?this.pathData.push(...t.pathData):(t.updateAccumulationLengths(),wt(t.pathData,t.accumulationLengths,e,i,this.pathData)),this.firstPointX=this.pathData[0],this.firstPointY=this.pathData[1],this.lastPointX=this.pathData[this.pathData.length-2],this.lastPointY=this.pathData[this.pathData.length-1],this}},Ot={draw(t,e,i){var s=this.toPoints();return e&&t.fillPoints(s,this.closePath,this.closePath),i&&t.strokePoints(s,this.closePath,this.closePath),this}};const Vt=Phaser.Geom.Polygon;class Lt{constructor(t){void 0===t&&(t=[]),this.pathData=t,this.closePath=!1,this.setIterations(32),this.firstPointX=void 0,this.firstPointY=void 0,this.lastPointX=void 0,this.lastPointY=void 0,this.accumulationLengths=void 0}setIterations(t){return this.iterations=t,this}toPoints(){return function(t,e){void 0===e&&(e=[]);for(var i=0,s=t.length-1;i<s;i+=2)e.push({x:t[i],y:t[i+1]});return e}(this.pathData)}toPolygon(t){return function(t,e){return void 0===e&&(e=new Vt),e.setTo(t),e}(this.pathData,t)}}Object.assign(Lt.prototype,Dt,bt,St,Mt,Ot);class Ft extends ut{constructor(){super(),this.builder=new Lt(this.pathData)}get iterations(){return this.builder.iterations}set iterations(t){this.dirty=this.dirty||this.builder.iterations!==t,this.builder.setIterations(t)}setIterations(t){return this.iterations=t,this}get lastPointX(){return this.builder.lastPointX}get lastPointY(){return this.builder.lastPointY}start(){return this.builder.start(),this.dirty=!0,this}startAt(t,e){return this.builder.startAt(t,e),this.dirty=!0,this}lineTo(t,e,i){return this.builder.lineTo(t,e,i),this.dirty=!0,this}verticalLineTo(t,e){return this.builder.verticalLineTo(t,e),this.dirty=!0,this}horizontalLineTo(t,e){return this.builder.horizontalLineTo(t,e),this.dirty=!0,this}ellipticalArc(t,e,i,s,h,r,a){return this.builder.ellipticalArc(t,e,i,s,h,r,a),this.dirty=!0,this}arc(t,e,i,s,h,r){return this.builder.arc(t,e,i,s,h,r),this.dirty=!0,this}quadraticBezierTo(t,e,i,s){return this.builder.quadraticBezierTo(t,e,i,s),this.dirty=!0,this}cubicBezierTo(t,e,i,s,h,r){return this.builder.cubicBezierTo(t,e,i,s,h,r),this.dirty=!0,this}catmullRomTo(...t){return this.builder.catmullRomTo(...t),this.dirty=!0,this}close(){return this.builder.close(),this.closePath=this.builder.closePath,this.dirty=!0,this}end(){return this.builder.end(),this.dirty=!0,this}rotateAround(t,e,i){return this.builder.rotateAround(t,e,i),this.dirty=!0,this}scale(t,e,i,s){return this.builder.scale(t,e,i,s),this.dirty=!0,this}offset(t,e){return this.builder.offset(t,e),this.dirty=!0,this}toPolygon(t){return this.builder.toPolygon(t)}appendPathFrom(t,e,i){return this.builder.appendFromPathSegment(t.builder,e,i),this}copyPathFrom(t,e,i){return this.builder.clear().appendFromPathSegment(t.builder,e,i),this}setDisplayPathSegment(t,e){return this.builder.setDisplayPathSegment(t,e),this}}const jt=Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlpha;Object.assign(class extends J{constructor(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=i),super(),this.pathData=[],this.isDashed=!1,this.strokePathData=void 0,this.strokePathMask=void 0,this.dashPattern=void 0,this.dashOffset=0,this.closePath=!0,this.setTopLeftPosition(t,e),this.setSize(i,s)}get x(){return this._x}set x(t){this.dirty=this.dirty||this._x!==t,this._x=t}get y(){return this._y}set y(t){this.dirty=this.dirty||this._y!==t,this._y=t}setTopLeftPosition(t,e){return this.x=t,this.y=e,this}get width(){return this._width}set width(t){this.dirty=this.dirty||this._width!==t,this._width=t}get height(){return this._height}set height(t){this.dirty=this.dirty||this._height!==t,this._height=t}setSize(t,e){return this.width=t,this.height=e,this}get centerX(){return this.x+this.width/2}set centerX(t){this.x=t-this.width/2}get centerY(){return this.y+this.height/2}set centerY(t){this.y=t-this.height/2}setCenterPosition(t,e){return this.centerX=t,this.centerY=e,this}updateData(){this.pathData.length=0;var t=this.x,e=t+this.width,i=this.y,s=i+this.height;return this.pathData.push(t,i),this.pathData.push(e,i),this.pathData.push(e,s),this.pathData.push(t,s),this.pathData.push(t,i),super.updateData(),this.buildStrokePath(),this}webglRender(t,e,i,s,h){if(this.isFilled){var r=t.fillTint,a=jt(this.fillColor,this.fillAlpha*i);r.TL=a,r.TR=a,r.BL=a,r.BR=a,t.batchFillRect(-s+this.x,-h+this.y,this.width,this.height)}this.isStroked&&Q(t,this,i,s,h)}canvasRender(t,e,i){this.isFilled&&(Z(t,this),t.fillRect(-e,-i,this.width,this.height)),this.isStroked&&tt(t,this,e,i)}}.prototype,ot),Phaser.Utils.Objects.GetValue;const Xt=Phaser.Geom.Polygon.Earcut;Object.assign(class extends J{constructor(t,e,i,s,h,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===h&&(h=0),void 0===r&&(r=0),super(),this.pathData=[],this.isDashed=!1,this.strokePathData=void 0,this.strokePathMask=void 0,this.dashPattern=void 0,this.dashOffset=0,this.pathIndexes=[],this.closePath=!0,this.setP0(t,e),this.setP1(i,s),this.setP2(h,r)}get x0(){return this._x0}set x0(t){this.dirty=this.dirty||this._x0!==t,this._x0=t}get y0(){return this._y0}set y0(t){this.dirty=this.dirty||this._y0!==t,this._y0=t}setP0(t,e){return this.x0=t,this.y0=e,this}get x1(){return this._x1}set x1(t){this.dirty=this.dirty||this._x1!==t,this._x1=t}get y1(){return this._y1}set y1(t){this.dirty=this.dirty||this._y1!==t,this._y1=t}setP1(t,e){return this.x1=t,this.y1=e,this}get x2(){return this._x2}set x2(t){this.dirty=this.dirty||this._x2!==t,this._x2=t}get y2(){return this._y2}set y2(t){this.dirty=this.dirty||this._y2!==t,this._y2=t}setP2(t,e){return this.dirty=this.dirty||this.x2!==t||this.y2!==e,this.x2=t,this.y2=e,this}updateData(){return this.pathData.length=0,this.pathData.push(this.x0,this.y0),this.pathData.push(this.x1,this.y1),this.pathData.push(this.x2,this.y2),this.pathData.push(this.x0,this.y0),this.pathIndexes=Xt(this.pathData),super.updateData(),this.buildStrokePath(),this}webglRender(t,e,i,s,h){this.isFilled&&K(t,e,this,i,s,h),this.isStroked&&Q(t,this,i,s,h)}canvasRender(t,e,i){this.isFilled&&$(t,this,e,i),this.isStroked&&tt(t,this,e,i)}}.prototype,ot);const Yt=Phaser.Math.RadToDeg,zt=Phaser.Math.DegToRad;var Nt=function(t,e,i,s,h,r,a,n){var o=360===Math.abs(a-r),l=zt(r),u=zt(a),d=Math.cos(l),p=Math.sin(l),c=Math.cos(u),v=Math.sin(u);return t.startAt(e+d*s,i+p*s),t.arc(e,i,s,r,a,n),o&&0===h||(t.lineTo(e+c*h,i+v*h),h>0&&t.arc(e,i,h,a,r,!n)),t.close(),t},Gt={buildShapes(){var t=this.iterations;this.addShape((new Ft).setIterations(t).setName("track")).addShape((new Ft).setIterations(t).setName("bar")).addShape((new gt).setIterations(t).setName("center"))},updateShapes(){var t=this.radius,e=this.thickness*this.radius,i=this.radius,s=i-e,h=this.getShape("track");null!=this.trackColor&&this.thickness>0?(h.fillStyle(this.trackColor,this.trackAlpha),Nt(h,t,t,i,s,0,360,!1)):h.reset();var r,a,n,o=this.getShape("bar");null!=this.barColor&&this.thickness>0?(1===this.value?(r=!1,a=0,n=360):(r=this.anticlockwise,a=Yt(this.startAngle),n=360*(r?1-this.value:this.value)+a),o.fillStyle(this.barColor,this.barAlpha),Nt(o,t,t,i+1,s-1,a,n,!1)):o.reset();var l=this.getShape("center");this.centerColor&&s>0?l.setCenterPosition(t,t).setRadius(s).fillStyle(this.centerColor,this.centerAlpha):l.reset()}};const It=Phaser.Utils.Objects.GetValue,Bt=Phaser.Utils.Objects.IsPlainObject,Wt=Phaser.Math.Clamp,Ut=Phaser.Math.DegToRad(270);class Jt extends(function(t){class e extends t{bootProgressBase(t){this.eventEmitter=N(t,"eventEmitter",this);var e=N(t,"valuechangeCallback",null);if(null!==e){var i=N(t,"valuechangeCallbackScope",void 0);this.eventEmitter.on("valuechange",e,i)}return this.setEaseValuePropName("value").setEaseValueDuration(N(t,"easeValue.duration",0)).setEaseValueFunction(N(t,"easeValue.ease","Linear")),this}get value(){return this._value}set value(t){t=G(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)}}return Object.assign(e.prototype,l,z),e}(a)){constructor(t,e,i,s,h,r,a){var n,o,l,u,d;Bt(e)&&(e=It(a=e,"x",0),i=It(a,"y",0),s=It(a,"radius",1),h=It(a,"barColor",void 0),r=It(a,"value",0)),n=It(a,"barAlpha",1),o=It(a,"trackColor",void 0),l=It(a,"trackAlpha",1),u=It(a,"centerColor",void 0),d=It(a,"centerAlpha",1),void 0===s&&(s=1);var p=2*s;super(t,e,i,p,p),this.type="rexCircularProgress",this.bootProgressBase(a),this.setRadius(s),this.setTrackColor(o,l),this.setBarColor(h,n),this.setCenterColor(u,d),this.setThickness(It(a,"thickness",.2)),this.setStartAngle(It(a,"startAngle",Ut)),this.setAnticlockwise(It(a,"anticlockwise",!1)),this.iterations=It(a,"iterations",128),this.buildShapes(),this.setValue(r)}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){this.dirty=this.dirty||this._trackColor!=t,this._trackColor=t}get trackAlpha(){return this._trackColor}set trackAlpha(t){this.dirty=this.dirty||this._trackAlpha!=t,this._trackAlpha=t}setTrackColor(t,e){return void 0===e&&(e=1),this.trackColor=t,this.trackAlpha=e,this}get barColor(){return this._barColor}set barColor(t){this.dirty=this.dirty||this._barColor!=t,this._barColor=t}get barAlpha(){return this._barAlpha}set barAlpha(t){this.dirty=this.dirty||this._barAlpha!=t,this._barAlpha=t}setBarColor(t,e){return void 0===e&&(e=1),this.barColor=t,this.barAlpha=e,this}get startAngle(){return this._startAngle}set startAngle(t){this.dirty=this.dirty||this._startAngle!=t,this._startAngle=t}setStartAngle(t){return this.startAngle=t,this}get anticlockwise(){return this._anticlockwise}set anticlockwise(t){this.dirty=this.dirty||this._anticlockwise!=t,this._anticlockwise=t}setAnticlockwise(t){return void 0===t&&(t=!0),this.anticlockwise=t,this}get thickness(){return this._thickness}set thickness(t){t=Wt(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){this.dirty=this.dirty||this._centerColor!=t,this._centerColor=t}get centerAlpha(){return this._centerAlpha}set centerAlpha(t){this.dirty=this.dirty||this._centerAlpha!=t,this._centerAlpha=t}setCenterColor(t,e){return void 0===e&&(e=1),this.centerColor=t,this.centerAlpha=e,this}}return Object.assign(Jt.prototype,Gt),Jt},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexcircularprogress=e();