UNPKG

phaser4-rex-plugins

Version:
2 lines (1 loc) 36.2 kB
var t,i;t=void 0,i=function(){const t=Phaser.GameObjects.GetCalcMatrix,i=Phaser.Renderer.Canvas.SetTransform;var s={renderWebGL:function(i,s,e,h){s.updateData();var r=e.camera;r.addToRenderList(s);for(var a,n=t(s,r,h,!e.useCanvas).calc,o=s._displayOriginX,u=s._displayOriginY,l=s.alpha,d=s.customRenderNodes.Submitter||s.defaultRenderNodes.Submitter,p=s.geom,c=0,y=p.length;c<y;c++)(a=p[c]).visible&&a.webglRender(e,d,n,s,l,o,u)},renderCanvas:function(t,s,e,h){s.updateData(),e.addToRenderList(s);var r=t.currentContext;if(i(t,r,s,e,h)){for(var a,n=s._displayOriginX,o=s._displayOriginY,u=s.geom,l=0,d=u.length;l<d;l++)(a=u[l]).visible&&a.canvasRender(r,n,o);r.restore()}}},e=function(t){if("object"!=typeof t||null===t)return t;if(Array.isArray(t))t.length=0;else for(var i in t)delete t[i];return t};const h=Phaser.GameObjects.Shape,r=Phaser.Utils.Array.Remove;class a extends h{constructor(t,i,s,e,h){void 0===i&&(i=0),void 0===s&&(s=0),void 0===e&&(e=2),void 0===h&&(h=e),super(t,"rexShapes",[]),this._width=-1,this._height=-1,this.dirty=!0,this.isSizeChanged=!0,this.shapes={},this.setPosition(i,s),this.setSize(e,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,i){this.isSizeChanged=this.isSizeChanged||this._width!==t||this._height!==i,this.dirty=this.dirty||this.isSizeChanged,this._width=t,this._height=i,this.updateDisplayOrigin();var s=this.input;return s&&!s.customHitArea&&(s.hitArea.width=t,s.hitArea.height=i),this}resize(t,i){return this.setSize(t,i),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,i){return void 0===i&&(i=1),this.dirty=this.dirty||this.fillColor!==t||this.fillAlpha!==i,this._fillColor=t,this._fillAlpha=i,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,i,s){return void 0===s&&(s=1),this.dirty=this.dirty||this.lineWidth!==t||this.strokeColor!==i||this.strokeAlpha!==s,this._lineWidth=t,this._strokeColor=i,this._strokeAlpha=s,this}updateShapes(){}updateData(){if(!this.dirty)return this;this.updateShapes();for(var t=this.geom,i=0,s=t.length;i<s;i++){var e=t[i];e.dirty&&e.updateData()}return this.isSizeChanged=!1,this.dirty=!1,this}clear(){return this.geom.length=0,e(this.shapes),this.dirty=!0,this}getShape(t){return this.shapes[t]}getShapes(){return this.geom}addShape(t){this.geom.push(t);var i=t.name;return i&&(this.shapes[i]=t),this.dirty=!0,this}deleteShape(t){var i=this.getShape(t);return i&&(delete this.shapes[t],r(this.geom,i)),this}}Object.assign(a.prototype,s);var n={setEventEmitter(t,i){return void 0===i&&(i=Phaser.Events.EventEmitter),this._privateEE=!0===t||void 0===t,this._eventEmitter=this._privateEE?new i: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 o=Phaser.Scene;var u=function(t){return t instanceof o};const l=Phaser.Game;var d=function(t){return t instanceof l};const p=Phaser.Utils.Objects.GetValue;class c{constructor(t,i){this.setParent(t),this.isShutdown=!1,this.setEventEmitter(p(i,"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,i){this.destroy(i)}setParent(t){var i;return this.parent=t,this.scene=null==(i=t)||"object"!=typeof i?null:u(i)?i:i.scene&&u(i.scene)?i.scene:i.parent&&i.parent.scene&&u(i.parent.scene)?i.parent.scene:null,this.game=function(t){return null==t||"object"!=typeof t?null:d(t)?t:d(t.game)?t.game:u(t)?t.sys.game:u(t.scene)?t.scene.sys.game:void 0}(t),this}}Object.assign(c.prototype,n);const y=Phaser.Utils.Objects.GetValue;class v extends c{constructor(t,i){super(t,i),this._isRunning=!1,this.isPaused=!1,this.tickingState=!1,this.setTickingMode(y(i,"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=g[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 g={no:0,lazy:1,always:2},m=Phaser.Utils.Objects.GetValue;class f extends v{constructor(t,i){super(t,i);var s=this.scene?"update":"step";this.tickEventName=m(i,"tickEventName",s),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 D=Phaser.Utils.Objects.GetValue,P=Phaser.Math.Clamp;class T{constructor(t){this.resetFromJSON(t)}resetFromJSON(t){this.state=D(t,"state",x),this.timeScale=D(t,"timeScale",1),this.delay=D(t,"delay",0),this.repeat=D(t,"repeat",0),this.repeatCounter=D(t,"repeatCounter",0),this.repeatDelay=D(t,"repeatDelay",0),this.duration=D(t,"duration",0),this.nowTime=D(t,"nowTime",0),this.justRestart=D(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?S:b,this.repeatCounter=0,this}stop(){return this.state=x,this}update(t,i){this.state!==x&&this.state!==R&&0!==i&&0!==this.timeScale&&(this.nowTime+=i*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=k)):(this.nowTime=this.duration,this.state=R):this.nowTime>=0&&(this.state=S))}get t(){var t;switch(this.state){case x:case b:case k:t=0;break;case S:t=this.nowTime/this.duration;break;case R:t=1}return P(t,0,1)}set t(t){(t=P(t,-1,1))<0?(this.state=b,this.nowTime=-this.delay*t):(this.state=S,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++)}setT(t){return this.t=t,this}get isIdle(){return this.state===x}get isDelay(){return this.state===b}get isCountDown(){return this.state===S}get isRunning(){return this.state===b||this.state===S}get isDone(){return this.state===R}get isOddIteration(){return!(1&~this.repeatCounter)}get isEvenIteration(){return!(1&this.repeatCounter)}}const x=0,b=1,S=2,k=3,R=-1;class w extends f{constructor(t,i){super(t,i),this.timer=new T}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 A=Phaser.Utils.Objects.GetValue,E=Phaser.Utils.Objects.GetAdvancedValue,C=Phaser.Tweens.Builders.GetEaseFunction;class L extends w{resetFromJSON(t){return this.timer.resetFromJSON(A(t,"timer")),this.setEnable(A(t,"enable",!0)),this.setTarget(A(t,"target",this.parent)),this.setDelay(E(t,"delay",0)),this.setDuration(E(t,"duration",1e3)),this.setEase(A(t,"ease","Linear")),this.setRepeat(A(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=C(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,i){if(!this.isRunning||!this.enable||this.parent.hasOwnProperty("active")&&!this.parent.active)return this;var s=this.target,e=this.timer;return e.update(t,i),e.isDelay||this.updateTarget(s,e),this.emit("update",s,this),e.isDone&&this.complete(),this}updateTarget(t,i){}}const O=Phaser.Utils.Objects.GetValue,X=Phaser.Math.Linear;class Y extends L{constructor(t,i){super(t,i),this.resetFromJSON(),this.boot()}start(t){if(this.timer.isRunning)return this;var i=this.target;this.propertyKey=O(t,"key","value");var s=i[this.propertyKey];return this.fromValue=O(t,"from",s),this.toValue=O(t,"to",s),this.setEase(O(t,"ease",this.ease)),this.setDuration(O(t,"duration",this.duration)),this.setRepeat(O(t,"repeat",0)),this.setDelay(O(t,"delay",0)),this.setRepeatDelay(O(t,"repeatDelay",0)),this.timer.setDuration(this.duration).setRepeat(this.repeat).setDelay(this.delay).setRepeatDelay(this.repeatDelay),i[this.propertyKey]=this.fromValue,super.start(),this}updateTarget(t,i){var s=i.t;s=this.easeFn(s),t[this.propertyKey]=X(this.fromValue,this.toValue,s)}}var F={start:function(t){return this.easeValueTask||(this.easeValueTask=new Y(this,{eventEmitter:null})),void 0!==t&&(this.duration=t,this.easeValueTask.stop()),this.easeValueTask.isRunning||(this.easeValueTask.restart({key:"value",from:0,to:1,duration:this.duration,ease:this.ease,repeat:-1,delay:this.delay,repeatDelay:this.repeatDelay}),this.setDirty()),this},stop:function(){return this.easeValueTask?(this.easeValueTask.stop(),this.setDirty(),this):this},pause:function(){return this.easeValueTask?(this.easeValueTask.pause(),this.setDirty(),this):this},resume:function(){return this.easeValueTask?(this.easeValueTask.pause(),this.setDirty(),this):this}};const B=Phaser.Utils.Objects.GetValue;class j extends a{constructor(t,i){super(t,B(i,"x",0),B(i,"y",0),B(i,"width",64),B(i,"height",64)),this.resetFromConfig(i,!0),this.buildShapes(i),B(i,"start",!0)&&this.start()}resetFromConfig(t,i){var s;return void 0===i&&(i=!1),s=i?1e3:this.duration,this.setDuration(B(t,"duration",s)),s=i?"Linear":this.ease,this.setEase(B(t,"ease",s)),s=i?0:this.delay,this.setDelay(B(t,"delay",s)),s=i?0:this.repeatDelay,this.setRepeatDelay(B(t,"repeatDelay",s)),s=i?16777215:this.color,this.setColor(B(t,"color",s)),s=i?0:this.value,this.setValue(B(t,"value",s)),this}buildShapes(){}get centerX(){return this.width/2}get centerY(){return this.height/2}get radius(){return Math.min(this.centerX,this.centerY)}get color(){return this._color}set color(t){this.isColorChanged=this.isColorChanged||this._color!==t,this.dirty=this.dirty||this.isColorChanged,this._color=t,this.setShapesColor(t)}setColor(t){return this.color=t,this}setShapesColor(t){}get value(){return this._value}set value(t){t=Phaser.Math.Clamp(t,0,1),this.dirty=this.dirty||this._value!=t,this._value=t}setValue(t){return this.value=t,this}setDuration(t){return this.duration=t,this}setDelay(t){return this.delay=t,this}setRepeatDelay(t){return this.repeatDelay=t,this}setEase(t){return this.ease=t,this}get isRunning(){return!!this.tweenTask&&this.tweenTask.isRunning}}Object.assign(j.prototype,F);var M={fillStyle:function(t,i){return null==t?this.isFilled=!1:(void 0===i&&(i=1),this.isFilled=!0,this.fillColor=t,this.fillAlpha=i),this},lineStyle:function(t,i,s){return null==t||null==i?this.isStroked=!1:(void 0===s&&(s=1),this.isStroked=!0,this.lineWidth=t,this.strokeColor=i,this.strokeAlpha=s),this}},V={enableData(){return void 0===this.data&&(this.data={}),this},setData(t,i){if(this.enableData(),1===arguments.length){var s=t;for(t in s)this.data[t]=s[t]}else this.data[t]=i;return this},getData(t,i){return this.enableData(),void 0===t?this.data:function(t,i,s){if(!t||"number"==typeof t)return s;if("string"==typeof i){if(t.hasOwnProperty(i))return t[i];if(-1===i.indexOf("."))return s;i=i.split(".")}for(var e=i,h=t,r=s,a=0;a<e.length;a++){if(i=e[a],!h.hasOwnProperty(i)){r=s;break}h=r=h[i]}return r}(this.data,t,i)},incData(t,i,s){return void 0===s&&(s=0),this.enableData(),this.setData(t,this.getData(t,s)+i),this},mulData(t,i,s){return void 0===s&&(s=0),this.enableData(),this.setData(t,this.getData(t,s)*i),this},clearData(){return this.data&&e(this.data),this}};class z{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,i,s,e,h,r,a){}canvasRender(t,i,s){}updateData(){this.dirty=!1}}Object.assign(z.prototype,M,V);var N=Phaser.Renderer.WebGL.Utils,G=Phaser.Renderer.WebGL.Utils,I=function(t,i,s,e,h,r,a,n){var o=G.getTintAppendFloatAlpha(h.strokeColor,h.strokeAlpha*r),u=h.pathData,l=u.length-1,d=h.lineWidth,p=!h.closePath,c=e.customRenderNodes.StrokePath||e.defaultRenderNodes.StrokePath,y=[];p&&(l-=2);for(var v=0;v<l;v+=2){var g=u[v]-a,m=u[v+1]-n;v>0&&g===u[v-2]&&m===u[v-1]||y.push({x:g,y:m,width:d})}c.run(t,i,y,d,p,s,o,o,o,o)},U=function(t,i,s,e){var h=s||i.fillColor,r=e||i.fillAlpha,a=(16711680&h)>>>16,n=(65280&h)>>>8,o=255&h;t.fillStyle="rgba("+a+","+n+","+o+","+r+")"},W=function(t,i,s,e){var h=s||i.strokeColor,r=e||i.strokeAlpha,a=(16711680&h)>>>16,n=(65280&h)>>>8,o=255&h;t.strokeStyle="rgba("+a+","+n+","+o+","+r+")",t.lineWidth=i.lineWidth};const J=Phaser.Geom.Polygon.Earcut;class K extends z{constructor(){super(),this.pathData=[],this.pathIndexes=[],this.closePath=!1}updateData(){return this.pathIndexes=J(this.pathData),super.updateData(),this}webglRender(t,i,s,e,h,r,a){this.isFilled&&function(t,i,s,e,h,r,a,n){var o,u,l,d,p,c=N.getTintAppendFloatAlpha(h.fillColor,h.fillAlpha*r),y=h.pathData,v=h.pathIndexes,g=y.length,m=Array(2*g),f=Array(g),_=0,D=0;for(o=0;o<g;o+=2)u=y[o]-a,l=y[o+1]-n,d=s.getX(u,l),p=s.getY(u,l),m[_++]=d,m[_++]=p,f[D++]=c;i.batch(t,v,m,f)}(t,i,s,0,this,h,r,a),this.isStroked&&I(t,i,s,e,this,h,r,a)}canvasRender(t,i,s){var e=this.pathData,h=e.length-1,r=e[0]-i,a=e[1]-s;t.beginPath(),t.moveTo(r,a),this.closePath||(h-=2);for(var n=2;n<h;n+=2){var o=e[n]-i,u=e[n+1]-s;t.lineTo(o,u)}this.closePath&&t.closePath(),this.isFilled&&(U(t,this),t.fill()),this.isStroked&&(W(t,this),t.stroke())}}var q=function(t,i,s){var e=s.length;if(e>=2){var h=s[e-2],r=s[e-1];if(t===h&&i===r)return s}return s.push(t,i),s};const H=Phaser.Math.DegToRad;var Q=function(t,i,s,e,h,r,a,n,o){a&&r>h?r-=360:!a&&r<h&&(r+=360);var u=H(r-h)/n;h=H(h);for(var l=0;l<=n;l++){var d=h+u*l,p=t+s*Math.cos(d),c=i+e*Math.sin(d);q(p,c,o)}return o};const Z=Phaser.Math.DegToRad;class $ extends K{constructor(t,i,s,e,h,r,a,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===e&&(e=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,i),this.setRadius(s,e),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,i){return void 0===i&&(i=t),this.x=t,this.y=i,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,i){return void 0===i&&(i=t),this.radiusX=t,this.radiusY=i,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,i,s){return void 0===s&&(s=!1),this.startAngle=t,this.endAngle=i,this.anticlockwise=s,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),Q(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}canvasRender(t,i,s){t.beginPath();var e=this.x-i,h=this.y-s,r=Z(this.startAngle),a=Z(this.endAngle);this.pie&&(t.moveTo(e,h),t.lineTo(e+Math.cos(r)*this.radiusX,h+Math.sin(r)*this.radiusY)),t.ellipse(e,h,this.radiusX,this.radiusY,0,r,a,this.anticlockwise),this.pie&&t.lineTo(e,h),this.isFilled&&(U(t,this),t.fill()),this.isStroked&&(W(t,this),t.stroke())}}const tt=Phaser.Math.Interpolation.QuadraticBezier,it=Phaser.Math.Interpolation.CubicBezier,st=Phaser.Math.Interpolation.CatmullRom;var et=function(t){var i=t.length;if(i<2)return t;var s=t[i-2],e=t[i-1];return t.push(s),t.push(e),t},ht={clear(){return this.start(),this},start(){return this.startAt(),this},startAt(t,i){return this.restorePathData(),this.accumulationLengths=void 0,function(t,i,s){s.length=0,null!=t&&s.push(t,i)}(t,i,this.pathData),this.firstPointX=t,this.firstPointY=i,this.lastPointX=t,this.lastPointY=i,this},lineTo(t,i,s){return void 0===s&&(s=!1),s&&(t+=this.lastPointX,i+=this.lastPointY),q(t,i,this.pathData),this.lastPointX=t,this.lastPointY=i,this},verticalLineTo(t,i){return this.lineTo(t,this.lastPointY,i),this},horizontalLineTo(t,i){return this.lineTo(this.lastPointX,t,i),this},ellipticalArc(t,i,s,e,h,r,a){return void 0===a&&(a=!1),Q(t,i,s,e,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,i,s,e,h,r){return this.ellipticalArc(t,i,s,s,e,h,r),this},quadraticBezierTo(t,i,s,e){return function(t,i,s,e,h,r){for(var a=r.length,n=r[a-2],o=r[a-1],u=1,l=h-1;u<=l;u++){var d=u/l;r.push(tt(d,n,t,s),tt(d,o,i,e))}}(t,i,s,e,this.iterations,this.pathData),this.lastPointX=s,this.lastPointY=e,this},cubicBezierTo(t,i,s,e,h,r){return function(t,i,s,e,h,r,a,n){for(var o=n.length,u=n[o-2],l=n[o-1],d=1,p=a-1;d<=p;d++){var c=d/p;n.push(it(c,u,t,s,h),it(c,l,i,e,r))}}(t,i,s,e,h,r,this.iterations,this.pathData),this.lastPointX=h,this.lastPointY=r,this},catmullRomTo(...t){return function(t,i,s){for(var e=s.length,h=[s[e-2]],r=[s[e-1]],a=0,n=t.length;a<n;a+=2)h.push(t[a]),r.push(t[a+1]);a=1;for(var o=i-1;a<=o;a++){var u=a/o;s.push(st(h,u),st(r,u))}}(t,this.iterations,this.pathData),this.lastPointX=t[t.length-2],this.lastPointY=t[t.length-1],this},close(){var t=this.pathData[0],i=this.pathData[1];return t===this.lastPointX&&i===this.lastPointY||this.lineTo(t,i),this.closePath=!0,this},end(){return et(this.pathData),this}};const rt=Phaser.Math.RotateAround;var at=function(t,i,s){for(var e=0,h=s.length-1;e<h;e+=2)s[e]+=t,s[e+1]+=i;return s};const nt=Phaser.Math.DegToRad;Phaser.Math.RotateAround;var ot={rotateAround(t,i,s){if(0===this.pathData.length)return this;!function(t,i,s,e){for(var h={x:0,y:0},r=0,a=e.length-1;r<a;r+=2)h.x=e[r],h.y=e[r+1],rt(h,t,i,s),e[r]=h.x,e[r+1]=h.y}(t,i,s=nt(s),this.pathData);var e=this.pathData.length;return this.lastPointX=this.pathData[e-2],this.lastPointY=this.pathData[e-1],this},scale(t,i,s,e){return 0===this.pathData.length||(function(t,i,s,e,h){for(var r=0,a=h.length-1;r<a;r+=2){var n=h[r]-t,o=h[r+1]-i;n*=s,o*=e,h[r]=n+t,h[r+1]=o+i}}(t,i,s,e,this.pathData),this.lastPointX=this.pathData[pathDataCnt-2],this.lastPointY=this.pathData[pathDataCnt-1]),this},offset(t,i){return at(t,i,this.pathData),this}},ut={savePathData(){return this.pathDataSaved||(this.pathDataSave=[...this.pathData],this.pathData.length=0,this.pathDataSaved=!0),this},restorePathData(){return this.pathDataSaved?(function(t,i,s,e){void 0===s&&(s=0),void 0===e&&(e=i.length),t.length=e-s;for(var h=0,r=t.length;h<r;h++)t[h]=i[h+s]}(this.pathData,this.pathDataSave),this.pathDataSave=void 0,this.pathDataSaved=!1,this):this}};const lt=Phaser.Math.Distance.Between,dt=Phaser.Math.Wrap,pt=Phaser.Math.Linear;var ct=function(t,i,s,e,h){if(void 0===e&&(e=s,s=0),(s=gt(s))!==(e=gt(e))){var r=i[i.length-1],a=r*s,n=r*e;s<e?yt(t,i,a,n,h):(yt(t,i,a,r,h),yt(t,i,0,n,h)),et(h)}},yt=function(t,i,s,e,h){for(var r=s>0,a=0,n=i.length;a<n;a++){var o=2*a,u=i[a];if(r){if(u<s)continue;if(u==s)r=!1;else{var l=1-(u-s)/(u-i[a-1]);h.push(vt(t,o-2,o,l)),h.push(vt(t,o-1,o+1,l)),r=!1}}if(!(u<=e)){l=1-(u-e)/(u-i[a-1]),h.push(vt(t,o-2,o,l)),h.push(vt(t,o-1,o+1,l));break}if(h.push(t[o]),h.push(t[o+1]),u===e)break}},vt=function(t,i,s,e){var h=t[i],r=t[s];return pt(h,r,e)},gt=function(t){return 0===t?0:t%1==0?1:dt(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,i,s,e,h=this.accumulationLengths,r=this.pathData,a=0,n=0,o=r.length;n<o;n+=2)s=r[n],e=r[n+1],a+=void 0===t?0:lt(t,i,s,e),h.push(a),t=s,i=e;return this.totalPathLength=a,this},setDisplayPathSegment(t,i){return this.pathDataSaved||(this.updateAccumulationLengths(),this.savePathData()),this.pathData.length=0,ct(this.pathDataSave,this.accumulationLengths,t,i,this.pathData),this},appendFromPathSegment(t,i,s){return void 0===i?this.pathData.push(...t.pathData):(t.updateAccumulationLengths(),ct(t.pathData,t.accumulationLengths,i,s,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}},ft={draw(t,i,s){var e=this.toPoints();return i&&t.fillPoints(e,this.closePath,this.closePath),s&&t.strokePoints(e,this.closePath,this.closePath),this}};const _t=Phaser.Geom.Polygon;class Dt{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,i){void 0===i&&(i=[]);for(var s=0,e=t.length-1;s<e;s+=2)i.push({x:t[s],y:t[s+1]});return i}(this.pathData)}toPolygon(t){return function(t,i){return void 0===i&&(i=new _t),i.setTo(t),i}(this.pathData,t)}}Object.assign(Dt.prototype,ht,ot,ut,mt,ft);var Pt=Phaser.Renderer.WebGL.Utils;const Tt=Phaser.Utils.Objects.GetValue;var xt=Phaser.Renderer.WebGL.Utils;const bt={arc:$,circle:class extends ${constructor(t,i,s){super(t,i,s,s,0,360)}},curve:class extends K{constructor(t){super(),this.setCurve(t),this.setIterations(32)}get curve(){return this._curve}set curve(t){this.dirty=this.dirty||this._curve!==t,this._curve=t}setCurve(t){return this.curve=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(){this.pathData.length=0;for(var t=this.curve.getPoints(this.iterations),i=0,s=t.length;i<s;i++)this.pathData.push(t[i].x,t[i].y);return this.pathData.push(t[0].x,t[0].y),super.updateData(),this}},ellipse:class extends ${constructor(t,i,s,e){super(t,i,s,e,0,360)}},line:class extends K{constructor(t,i,s,e){void 0===t&&(t=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===e&&(e=0),super(),this.setP0(t,i),this.setP1(s,e)}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,i){return this.x0=t,this.y0=i,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,i){return this.x1=t,this.y1=i,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.x0,this.y0),super.updateData(),this}},lines:class extends K{constructor(){super(),this.builder=new Dt(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,i){return this.builder.startAt(t,i),this.dirty=!0,this}lineTo(t,i,s){return this.builder.lineTo(t,i,s),this.dirty=!0,this}verticalLineTo(t,i){return this.builder.verticalLineTo(t,i),this.dirty=!0,this}horizontalLineTo(t,i){return this.builder.horizontalLineTo(t,i),this.dirty=!0,this}ellipticalArc(t,i,s,e,h,r,a){return this.builder.ellipticalArc(t,i,s,e,h,r,a),this.dirty=!0,this}arc(t,i,s,e,h,r){return this.builder.arc(t,i,s,e,h,r),this.dirty=!0,this}quadraticBezierTo(t,i,s,e){return this.builder.quadraticBezierTo(t,i,s,e),this.dirty=!0,this}cubicBezierTo(t,i,s,e,h,r){return this.builder.cubicBezierTo(t,i,s,e,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,i,s){return this.builder.rotateAround(t,i,s),this.dirty=!0,this}scale(t,i,s,e){return this.builder.scale(t,i,s,e),this.dirty=!0,this}offset(t,i){return this.builder.offset(t,i),this.dirty=!0,this}toPolygon(t){return this.builder.toPolygon(t)}appendPathFrom(t,i,s){return this.builder.appendFromPathSegment(t.builder,i,s),this}copyPathFrom(t,i,s){return this.builder.clear().appendFromPathSegment(t.builder,i,s),this}setDisplayPathSegment(t,i){return this.builder.setDisplayPathSegment(t,i),this}},rectangle:class extends z{constructor(t,i,s,e){void 0===t&&(t=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===e&&(e=s),super(),this.pathData=[],this.closePath=!0,this.setTopLeftPosition(t,i),this.setSize(s,e)}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,i){return this.x=t,this.y=i,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,i){return this.width=t,this.height=i,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,i){return this.centerX=t,this.centerY=i,this}updateData(){this.pathData.length=0;var t=this.x,i=t+this.width,s=this.y,e=s+this.height;return this.pathData.push(t,s),this.pathData.push(i,s),this.pathData.push(i,e),this.pathData.push(t,e),this.pathData.push(t,s),super.updateData(),this}webglRender(t,i,s,e,h,r,a){if(this.isFilled){var n=Pt.getTintAppendFloatAlpha(this.fillColor,this.fillAlpha*h);(e.customRenderNodes.FillRect||e.defaultRenderNodes.FillRect).run(t,s,i,-r+this.x,-a+this.y,this.width,this.height,n,n,n,n)}this.isStroked&&I(t,i,s,e,this,h,r,a)}canvasRender(t,i,s){this.isFilled&&(U(t,this),t.fillRect(-i,-s,this.width,this.height)),this.isStroked&&(W(t,this),t.beginPath(),t.rect(-i,-s,this.width,this.height),t.stroke())}},roundRectangle:class extends K{constructor(t,i,s,e,h,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===e&&(e=s),void 0===h&&(h=0),void 0===r&&(r=6),super(),this.setTopLeftPosition(t,i),this.setSize(s,e),this.setRadius(h),this.setIterations(r),this.closePath=!0}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,i){return this.x=t,this.y=i,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,i){return this.width=t,this.height=i,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,i){return this.centerX=t,this.centerY=i,this}get radiusTL(){return this._radiusTL}set radiusTL(t){var i=t>0;this.dirty=this.dirty||this._radiusTL!==t||this._convexTL!==i,this._convexTL=i,this._radiusTL=Math.abs(t)}get radiusTR(){return this._radiusTR}set radiusTR(t){var i=t>0;this.dirty=this.dirty||this._radiusTR!==t||this._convexTR!==i,this._convexTR=i,this._radiusTR=Math.abs(t)}get radiusBL(){return this._radiusBL}set radiusBL(t){var i=t>0;this.dirty=this.dirty||this._radiusBL!==t||this._convexBL!==i,this._convexBL=i,this._radiusBL=Math.abs(t)}get radiusBR(){return this._radiusBR}set radiusBR(t){var i=t>0;this.dirty=this.dirty||this._radiusBR!==t||this._convexBR!==i,this._convexBR=i,this._radiusBR=Math.abs(t)}get radius(){return Math.max(this.radiusTL,this.radiusTR,this.radiusBL,this.radiusBR)}set radius(t){"number"==typeof t?(this.radiusTL=t,this.radiusTR=t,this.radiusBL=t,this.radiusBR=t):(this.radiusTL=Tt(t,"tl",0),this.radiusTR=Tt(t,"tr",0),this.radiusBL=Tt(t,"bl",0),this.radiusBR=Tt(t,"br",0))}setRadius(t){return void 0===t&&(t=0),this.radius=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(){var t=this.pathData;t.length=0;var i,s=this.width,e=this.height,h=this.iterations+1;return(i=this.radiusTL)>0?this._convexTL?Q(i,i,i,i,180,270,!1,h,t):Q(0,0,i,i,90,0,!0,h,t):q(0,0,t),(i=this.radiusTR)>0?this._convexTR?Q(s-i,i,i,i,270,360,!1,h,t):Q(s,0,i,i,180,90,!0,h,t):q(s,0,t),(i=this.radiusBR)>0?this._convexBR?Q(s-i,e-i,i,i,0,90,!1,h,t):Q(s,e,i,i,270,180,!0,h,t):q(s,e,t),(i=this.radiusBL)>0?this._convexBL?Q(i,e-i,i,i,90,180,!1,h,t):Q(0,e,i,i,360,270,!0,h,t):q(0,e,t),t.push(t[0],t[1]),at(this.x,this.y,t),super.updateData(),this}},triangle:class extends z{constructor(t,i,s,e,h,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===e&&(e=0),void 0===h&&(h=0),void 0===r&&(r=0),super(),this.pathData=[],this.closePath=!0,this.setP0(t,i),this.setP1(s,e),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,i){return this.x0=t,this.y0=i,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,i){return this.x1=t,this.y1=i,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,i){return this.dirty=this.dirty||this.x2!==t||this.y2!==i,this.x2=t,this.y2=i,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),super.updateData(),this}webglRender(t,i,s,e,h,r,a){if(this.isFilled){var n=xt.getTintAppendFloatAlpha(this.fillColor,this.fillAlpha*h),o=this.x0-r,u=this.y0-a,l=this.x1-r,d=this.y1-a,p=this.x2-r,c=this.y2-a;(e.customRenderNodes.FillTri||e.defaultRenderNodes.FillTri).run(t,s,i,o,u,l,d,p,c,n,n,n)}this.isStroked&&I(t,i,s,e,this,h,r,a)}canvasRender(t,i,s){var e=this.x1-i,h=this.y1-s,r=this.x2-i,a=this.y2-s,n=this.x3-i,o=this.y3-s;t.beginPath(),t.moveTo(e,h),t.lineTo(r,a),t.lineTo(n,o),t.closePath(),this.isFilled&&(U(t,this),t.fill()),this.isStroked&&(W(t,this),t.stroke())}}},St=Phaser.Utils.Objects.GetValue,kt=Phaser.Utils.Objects.IsPlainObject,Rt=function(){for(var t=this.getShapes(),i=0,s=t.length;i<s;i++)t[i].lineStyle().fillStyle()};var wt={createShape(t,i){var s=new(0,bt[t]);return i&&s.setName(i),s},buildShapes(t){var i=St(t,"create",void 0);if(kt(i)){var s=i;for(var e in s){var h=s[e];switch(typeof h){case"number":for(var r=0;r<h;r++)this.addShape(this.createShape(e));break;case"string":this.addShape(this.createShape(e,h));break;default:for(var a=h,n=(r=0,a.length);r<n;r++)this.addShape(this.createShape(e,a[r]))}}}else if(Array.isArray(i))for(r=0,n=(s=i).length;r<n;r++){var o=s[r];this.addShape(this.createShape(o.type,o.name))}else"function"==typeof i&&i.call(this);this.setUpdateShapesCallback(St(t,"update"))},setUpdateShapesCallback(t){return void 0===t&&(t=Rt),this.dirty=this.dirty||this.updateCallback!==t,this.updateCallback=t,this},updateShapes(){this.updateCallback.call(this)}};const At=Phaser.Utils.Objects.GetValue;class Et extends j{constructor(t,i){super(t,i),this.type=At(i,"type","rexSpinnerCustom")}}return Object.assign(Et.prototype,wt),Et},"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t="undefined"!=typeof globalThis?globalThis:t||self).rexcustomspinner=i();