From c403db650754bf0d63d19d34e2c3d1824ac64475 Mon Sep 17 00:00:00 2001 From: Rex Date: Wed, 23 Oct 2024 13:12:05 +0800 Subject: [PATCH] fix canvas rendering --- dist/rexninepatch2plugin.js | 63 +++++++++++++++---- dist/rexninepatch2plugin.min.js | 2 +- dist/rexuiplugin.js | 63 +++++++++++++++---- dist/rexuiplugin.min.js | 2 +- .../blitterbase/bob/image/CanvasRender.js | 42 +++++++++++-- .../ninepatch/texture/DrawTileSprite.js | 21 +++++-- 6 files changed, 158 insertions(+), 35 deletions(-) diff --git a/dist/rexninepatch2plugin.js b/dist/rexninepatch2plugin.js index b05b9931bd..30f3e7a705 100644 --- a/dist/rexninepatch2plugin.js +++ b/dist/rexninepatch2plugin.js @@ -1508,6 +1508,10 @@ }; var CanvasRender = function (ctx, dx, dy, roundPixels) { + var frame = this.frame; + if (!frame) { + return; + } ctx.save(); @@ -1518,6 +1522,28 @@ var x = this.x - displayOriginX, y = this.y - displayOriginY; + var frameX, frameY; + var frameWidth, frameHeight; + if (this.isCropped) { + var crop = this._crop; + + if (crop.flipX !== this.flipX || crop.flipY !== this.flipY) { + frame.updateCropUVs(crop, this.flipX, this.flipY); + } + + frameWidth = crop.cw; + frameHeight = crop.ch; + + frameX = crop.cx; + frameY = crop.cy; + } else { + frameWidth = frame.cutWidth; + frameHeight = frame.cutHeight; + + frameX = frame.cutX; + frameY = frame.cutY; + } + var flipX = 1; var flipY = 1; @@ -1530,9 +1556,16 @@ flipY = -1; } + var res = frame.source.resolution; + var fw = frameWidth / res; + var fh = frameHeight / res; + if (roundPixels) { - x = Math.round(x); - y = Math.round(y); + x = Math.floor(x + 0.5); + y = Math.floor(y + 0.5); + + fw += 0.5; + fh += 0.5; } ctx.translate(x, y); @@ -1541,11 +1574,10 @@ ctx.scale(this.scaleX * flipX, this.scaleY * flipY); - var frame = this.frame; ctx.drawImage( frame.source.image, - frame.cutX, frame.cutY, width, height, - 0, 0, width, height, + frameX, frameY, frameWidth, frameHeight, + 0, 0, fw, fh, ); ctx.restore(); @@ -1791,16 +1823,25 @@ var DrawTileSprite = function (key, frame, x, y, width, height) { var frameObj = this.texture.get(frame); + var frameWidth = frameObj.width, frameHeight = frameObj.height; - var cropLastWidth = width % frameWidth, - cropLastHeight = height % frameHeight; - var cropLastCol = (cropLastWidth !== 0), - cropLastRow = (cropLastHeight !== 0); + + var lastFrameWidth = width % frameWidth, + lastFrameHeight = height % frameHeight; + + if (lastFrameWidth === 0) { + lastFrameWidth = frameWidth; + } + if (lastFrameHeight === 0) { + lastFrameHeight = frameHeight; + } + var colCount = Math.ceil(width / frameWidth), rowCount = Math.ceil(height / frameHeight); var lastColCount = colCount - 1, lastRowCount = rowCount - 1; + for (var colIndex = 0; colIndex < colCount; colIndex++) { for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) { let bob = AddImage(this, { @@ -1809,8 +1850,8 @@ y: y + (rowIndex * frameHeight), }); - var cropWidth = (cropLastCol && (colIndex === lastColCount)) ? cropLastWidth : frameWidth; - var cropHeight = (cropLastRow && (rowIndex === lastRowCount)) ? cropLastHeight : frameHeight; + var cropWidth = (colIndex === lastColCount) ? lastFrameWidth : frameWidth; + var cropHeight = (rowIndex === lastRowCount) ? lastFrameHeight : frameHeight; if ((cropWidth !== frameWidth) || (cropHeight !== frameHeight)) { bob.setCrop(0, 0, cropWidth, cropHeight); } diff --git a/dist/rexninepatch2plugin.min.js b/dist/rexninepatch2plugin.min.js index 0aca5f0a65..20ee05ca65 100644 --- a/dist/rexninepatch2plugin.min.js +++ b/dist/rexninepatch2plugin.min.js @@ -1 +1 @@ -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,r){var h=i.getRenderList();if(0!==h.length){s.addToRenderList(i);var a=e.pipelines.set(i.pipeline),n=i.frame.glTexture,o=a.setGameObject(i),l=s.roundPixels,d=t(i,s,r),c=a.calcMatrix.copyFrom(d.calc),u=i._displayOriginX,p=i._displayOriginY,g=s.alpha*i.alpha;e.pipelines.preBatch(i);for(var v=0,f=h.length;v0?this.items.pop():null}push(t){return this.items.push(t),this}pushMultiple(t){return this.items.push.apply(this.items,t),t.length=0,this}clear(){return this.items.length=0,this}}const l=Phaser.Utils.Objects.GetValue;var d={};class c{constructor(t){this.pools=l(t,"pools",d)}destroy(){this.pools=void 0}free(t){if(!this.pools)return this;var e=t.type;return this.pools.hasOwnProperty(e)||(this.pools[e]=new o),this.pools[e].push(t),t.onFree(),this}freeMultiple(t){if(!this.pools)return this;for(var e=0,i=t.length;e0},b=function(t,e){return t._depth-e._depth};const x=Phaser.GameObjects.Components;Phaser.Class.mixin(w,[x.Alpha,x.BlendMode,x.ComputedSize,x.Depth,x.GetBounds,x.Mask,x.Origin,x.Pipeline,x.PostPipeline,x.ScrollFactor,x.Transform,x.Visible,i,n]);var O=function(t,e,i){return"__BASE"===i?`${t},${e}`:`${i}:${t},${e}`};function _(t){if(null===t||"object"!=typeof t)return t;if(Array.isArray(t))return t.map((t=>_(t)));if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if(Object.getPrototypeOf(t)!==Object.prototype)return t;const e={};for(let i in t)t.hasOwnProperty(i)&&(e[i]=_(t[i]));return e}const F=Phaser.Utils.Objects.IsPlainObject,D=Phaser.Utils.Objects.GetValue;var X=function(t){return"string"==typeof t&&(t=Y[t]),t};const Y={scale:0,repeat:1};var S=function(t,e){return 0===t||t===this.columns.count-1||0===e||e===this.rows.count-1},M=function(){},C={_beginDraw:M,_drawImage:M,_drawTileSprite:M,_endDraw:M,setGetFrameNameCallback:function(t){return void 0===t&&(t=O),this.getFrameNameCallback=t,this},setBaseTexture:function(t,e,i,s){Array.isArray(e)&&(s=i,i=e,e=void 0),null==e&&(e="__BASE"),"number"==typeof i&&arguments.length>=6?(i=[arguments[2],void 0,arguments[3]],s=[arguments[4],void 0,arguments[5]]):void 0===i&&void 0===s&&void 0!==this.columns.data&&void 0!==this.rows.data?(i=this.columns.data,s=this.rows.data):(i=_(i),s=_(s)),this.textureKey=t,this.baseFrameName=e,this.columns.data=i,this.columns.count=i?i.length:0,this.columns.stretch=0,this.columns.minWidth=0,this.columns.scale=1,this.rows.data=s,this.rows.count=s?s.length:0,this.rows.stretch=0,this.rows.minHeight=0,this.rows.scale=1;var r=this.scene.sys.textures.get(t);if(!r)return this.clear(),this;if(!i||!s)return this.clear(),this;for(var h=r.get(e),a=h.width,n=0,o=0,l=i.length;o0?a/n:0,c=h.height,u=0;for(o=0,l=s.length;o0?0:v,w=0,o=0;for(var O=i.length;o0?0:f),f>=1&&v>=1){var F=typeof(m=this.getFrameNameCallback(o,b,e));"string"!==F&&"number"!==F||r.add(m,0,w+h.cutX,P+h.cutY,f,v)}w+=f}P+=v}return this.updateTexture(),this},updateTexture:function(){if(this.clear(),void 0===this.textureKey)return this;var t=this.scene.sys.textures.get(this.textureKey);if(!t)return this;var e,i,s,r,h,a,n,o=this.columns.minWidth*this.maxFixedPartScaleX,l=this.rows.minHeight*this.maxFixedPartScaleY,d=this.width-o,c=this.height-l,u=d>=0?this.maxFixedPartScaleX:this.width/o,p=c>=0?this.maxFixedPartScaleY:this.height/l;if(this.preserveRatio){var g=Math.min(u,p);if(u>g){var v=(u-g)*o;d>=0?d+=v:d=v,u=g}if(p>g){var f=(p-g)*l;c>=0?c+=f:c=f,p=g}}this.columns.scale=u,this.rows.scale=p,e=d>0&&this.columns.stretch>0?d/this.columns.stretch:0,i=c>0&&this.rows.stretch>0?c/this.rows.stretch:0;var m=0,y=0;this._beginDraw();for(var w=0,P=this.rows.count;w0&&n>0&&(0==(0===h.stretch&&0===r.stretch||0===this.getStretchMode(b,w)?0:1)?this._drawImage(this.textureKey,s,m,y,a,n):this._drawTileSprite(this.textureKey,s,m,y,a,n)),m+=a;y+=n}this._endDraw()},setStretchMode:function(t){return F(t)?(this.stretchMode.edge=X(D(t,"edge",0)),this.stretchMode.internal=X(D(t,"internal",0))):(t=X(t),this.stretchMode.edge=t,this.stretchMode.internal=t),this},getStretchMode:function(t,e){return S.call(this,t,e)?this.stretchMode.edge:this.stretchMode.internal},setPreserveRatio:function(t){return null==t&&(t=!0),this.preserveRatio=t,this},setMaxFixedPartScale:function(t,e){return void 0===e&&(e=t),this.maxFixedPartScaleX=t,this.maxFixedPartScaleY=e,this}};const T=Phaser.Utils.Objects.IsPlainObject,A=Phaser.Utils.Objects.GetValue,j="image";var R={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){if(!t||"number"==typeof t)return i;if("string"==typeof e){if(t.hasOwnProperty(e))return t[e];if(-1===e.indexOf("."))return i;e=e.split(".")}for(var s=e,r=t,h=i,a=0;a0&&!I(t)&&(t=this.parent.texture.get(t)),this.frame=t,t?(this._width=t.realWidth,this._height=t.realHeight):(this._width=0,this._height=0),this}setFlipX(t){return void 0===t&&(t=!0),this.flipX=t,this}setFlipY(t){return void 0===t&&(t=!0),this.flipY=t,this}resetFlip(){return this.flipX=!1,this.flipY=!1,this}get tint(){return void 0===this._tint?this.parent.tint:this._tint}set tint(t){this._tint=t}setTint(t){return this.tint=t,this.tintFill=!1,this}setTintFill(t){return this.tint=t,this.tintFill=!0,this}clearTint(){return this.setTint(16777215),this}resetTint(){return this.tint=void 0,this.tintFill=void 0,this}get tintFill(){return void 0===this._tintFill?this.parent.tintFill:this._tintFill}set tintFill(t){this._tintFill=t}setCrop(t,e,i,s){return void 0===t?(this.isCropped=!1,this):this.frame?0===t&&0===e&&i===this._width&&s===this._height?(this.isCropped=!1,this):(this.frame.setCropUVs(this._crop,t,e,i,s,this.flipX,this.flipY),this.isCropped=!0,this):this}reset(){return super.reset(),this.resetFlip().resetTint().setFrame().setCrop(),this}modifyPorperties(t){return t?(t.hasOwnProperty("width")&&(t.displayWidth=t.width,delete t.width),t.hasOwnProperty("height")&&(t.displayHeight=t.height,delete t.height),t.hasOwnProperty("frame")&&this.setFrame(t.frame),super.modifyPorperties(t),t.hasOwnProperty("flipX")&&this.setFlipX(t.flipX),t.hasOwnProperty("flipY")&&this.setFlipY(t.flipY),t.hasOwnProperty("tint")&&this.setTint(t.tint),t.hasOwnProperty("tintFill")&&this.setTintFill(t.tintFill),this):this}}var z=function(t){return void 0===t&&(t={}),t.u0=0,t.v0=0,t.u1=0,t.v1=0,t.x=0,t.y=0,t.width=0,t.height=0,t.flipX=!1,t.flipY=!1,t.cx=0,t.cy=0,t.cw=0,t.ch=0,t},$={webglRender:function(t,e,i,s,r,h,a,n){var o=this.frame;if(o){var l,d,c,u,p,g,v,f,m=this._width,y=this._height,w=m*this.originX,P=y*this.originY,b=this.x-s,x=this.y-r;if(this.isCropped){var O=this._crop;O.flipX===this.flipX&&O.flipY===this.flipY||o.updateCropUVs(O,this.flipX,this.flipY),l=O.u0,d=O.v0,c=O.u1,u=O.v1,v=O.width,f=O.height,p=O.x,g=O.y}else l=this.frame.u0,d=this.frame.v0,c=this.frame.u1,u=this.frame.v1,v=m,f=y,p=0,g=0;var _=1,F=1;this.flipX&&(b+=m-2*w,_=-1),this.flipY&&(x+=y-2*P,F=-1),k.applyITRS(b,x,this.rotation,this.scaleX*_,this.scaleY*F),e.multiply(k,k);var D=-w+p,X=-P+g,Y=D+v,S=X+f,M=k.setQuad(D,X,Y,S,n),C=N(this.tint,this.alpha*i);t.batchQuad(this.parent,M[0],M[1],M[2],M[3],M[4],M[5],M[6],M[7],l,d,c,u,C,C,C,C,this.tintFill,h,a)}},canvasRender:function(t,e,i,s){t.save();var r=this._width,h=this._height,a=r*this.originX,n=h*this.originY,o=this.x-a,l=this.y-n,d=1,c=1;this.flipX&&(o+=r,d=-1),this.flipY&&(l+=h,c=-1),s&&(o=Math.round(o),l=Math.round(l)),t.translate(o,l),t.rotate(this.rotation),t.scale(this.scaleX*d,this.scaleY*c);var u=this.frame;t.drawImage(u.source.image,u.cutX,u.cutY,r,h,0,0,r,h),t.restore()}};Object.assign(V.prototype,$);var E=function(t,e){"string"==typeof e&&(e={frame:e});var i=t.poolManager?t.poolManager.allocate(j):null;return null===i?i=new V(t):i.setParent(t).setActive(),i.modifyPorperties(e),t.addChild(i),i},K={_drawImage:function(t,e,i,s,r,h){E(this,{frame:e,x:i,y:s,width:r,height:h})},_drawTileSprite:function(t,e,i,s,r,h){for(var a=this.texture.get(e),n=a.width,o=a.height,l=r%n,d=h%o,c=0!==l,u=0!==d,p=Math.ceil(r/n),g=Math.ceil(h/o),v=p-1,f=g-1,m=0;m0?this.items.pop():null}push(t){return this.items.push(t),this}pushMultiple(t){return this.items.push.apply(this.items,t),t.length=0,this}clear(){return this.items.length=0,this}}const l=Phaser.Utils.Objects.GetValue;var d={};class c{constructor(t){this.pools=l(t,"pools",d)}destroy(){this.pools=void 0}free(t){if(!this.pools)return this;var i=t.type;return this.pools.hasOwnProperty(i)||(this.pools[i]=new o),this.pools[i].push(t),t.onFree(),this}freeMultiple(t){if(!this.pools)return this;for(var i=0,e=t.length;i0},b=function(t,i){return t._depth-i._depth};const x=Phaser.GameObjects.Components;Phaser.Class.mixin(w,[x.Alpha,x.BlendMode,x.ComputedSize,x.Depth,x.GetBounds,x.Mask,x.Origin,x.Pipeline,x.PostPipeline,x.ScrollFactor,x.Transform,x.Visible,e,n]);var O=function(t,i,e){return"__BASE"===e?`${t},${i}`:`${e}:${t},${i}`};function _(t){if(null===t||"object"!=typeof t)return t;if(Array.isArray(t))return t.map((t=>_(t)));if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if(Object.getPrototypeOf(t)!==Object.prototype)return t;const i={};for(let e in t)t.hasOwnProperty(e)&&(i[e]=_(t[e]));return i}const F=Phaser.Utils.Objects.IsPlainObject,X=Phaser.Utils.Objects.GetValue;var Y=function(t){return"string"==typeof t&&(t=D[t]),t};const D={scale:0,repeat:1};var S=function(t,i){return 0===t||t===this.columns.count-1||0===i||i===this.rows.count-1},C=function(){},M={_beginDraw:C,_drawImage:C,_drawTileSprite:C,_endDraw:C,setGetFrameNameCallback:function(t){return void 0===t&&(t=O),this.getFrameNameCallback=t,this},setBaseTexture:function(t,i,e,s){Array.isArray(i)&&(s=e,e=i,i=void 0),null==i&&(i="__BASE"),"number"==typeof e&&arguments.length>=6?(e=[arguments[2],void 0,arguments[3]],s=[arguments[4],void 0,arguments[5]]):void 0===e&&void 0===s&&void 0!==this.columns.data&&void 0!==this.rows.data?(e=this.columns.data,s=this.rows.data):(e=_(e),s=_(s)),this.textureKey=t,this.baseFrameName=i,this.columns.data=e,this.columns.count=e?e.length:0,this.columns.stretch=0,this.columns.minWidth=0,this.columns.scale=1,this.rows.data=s,this.rows.count=s?s.length:0,this.rows.stretch=0,this.rows.minHeight=0,this.rows.scale=1;var r=this.scene.sys.textures.get(t);if(!r)return this.clear(),this;if(!e||!s)return this.clear(),this;for(var h=r.get(i),a=h.width,n=0,o=0,l=e.length;o0?a/n:0,c=h.height,u=0;for(o=0,l=s.length;o0?0:v,w=0,o=0;for(var O=e.length;o0?0:f),f>=1&&v>=1){var F=typeof(m=this.getFrameNameCallback(o,b,i));"string"!==F&&"number"!==F||r.add(m,0,w+h.cutX,P+h.cutY,f,v)}w+=f}P+=v}return this.updateTexture(),this},updateTexture:function(){if(this.clear(),void 0===this.textureKey)return this;var t=this.scene.sys.textures.get(this.textureKey);if(!t)return this;var i,e,s,r,h,a,n,o=this.columns.minWidth*this.maxFixedPartScaleX,l=this.rows.minHeight*this.maxFixedPartScaleY,d=this.width-o,c=this.height-l,u=d>=0?this.maxFixedPartScaleX:this.width/o,p=c>=0?this.maxFixedPartScaleY:this.height/l;if(this.preserveRatio){var g=Math.min(u,p);if(u>g){var v=(u-g)*o;d>=0?d+=v:d=v,u=g}if(p>g){var f=(p-g)*l;c>=0?c+=f:c=f,p=g}}this.columns.scale=u,this.rows.scale=p,i=d>0&&this.columns.stretch>0?d/this.columns.stretch:0,e=c>0&&this.rows.stretch>0?c/this.rows.stretch:0;var m=0,y=0;this._beginDraw();for(var w=0,P=this.rows.count;w0&&n>0&&(0==(0===h.stretch&&0===r.stretch||0===this.getStretchMode(b,w)?0:1)?this._drawImage(this.textureKey,s,m,y,a,n):this._drawTileSprite(this.textureKey,s,m,y,a,n)),m+=a;y+=n}this._endDraw()},setStretchMode:function(t){return F(t)?(this.stretchMode.edge=Y(X(t,"edge",0)),this.stretchMode.internal=Y(X(t,"internal",0))):(t=Y(t),this.stretchMode.edge=t,this.stretchMode.internal=t),this},getStretchMode:function(t,i){return S.call(this,t,i)?this.stretchMode.edge:this.stretchMode.internal},setPreserveRatio:function(t){return null==t&&(t=!0),this.preserveRatio=t,this},setMaxFixedPartScale:function(t,i){return void 0===i&&(i=t),this.maxFixedPartScaleX=t,this.maxFixedPartScaleY=i,this}};const T=Phaser.Utils.Objects.IsPlainObject,A=Phaser.Utils.Objects.GetValue,j="image";var R={enableData(){return void 0===this.data&&(this.data={}),this},setData(t,i){if(this.enableData(),1===arguments.length){var e=t;for(t in e)this.data[t]=e[t]}else this.data[t]=i;return this},getData(t,i){return this.enableData(),void 0===t?this.data:function(t,i,e){if(!t||"number"==typeof t)return e;if("string"==typeof i){if(t.hasOwnProperty(i))return t[i];if(-1===i.indexOf("."))return e;i=i.split(".")}for(var s=i,r=t,h=e,a=0;a0&&!k(t)&&(t=this.parent.texture.get(t)),this.frame=t,t?(this._width=t.realWidth,this._height=t.realHeight):(this._width=0,this._height=0),this}setFlipX(t){return void 0===t&&(t=!0),this.flipX=t,this}setFlipY(t){return void 0===t&&(t=!0),this.flipY=t,this}resetFlip(){return this.flipX=!1,this.flipY=!1,this}get tint(){return void 0===this._tint?this.parent.tint:this._tint}set tint(t){this._tint=t}setTint(t){return this.tint=t,this.tintFill=!1,this}setTintFill(t){return this.tint=t,this.tintFill=!0,this}clearTint(){return this.setTint(16777215),this}resetTint(){return this.tint=void 0,this.tintFill=void 0,this}get tintFill(){return void 0===this._tintFill?this.parent.tintFill:this._tintFill}set tintFill(t){this._tintFill=t}setCrop(t,i,e,s){return void 0===t?(this.isCropped=!1,this):this.frame?0===t&&0===i&&e===this._width&&s===this._height?(this.isCropped=!1,this):(this.frame.setCropUVs(this._crop,t,i,e,s,this.flipX,this.flipY),this.isCropped=!0,this):this}reset(){return super.reset(),this.resetFlip().resetTint().setFrame().setCrop(),this}modifyPorperties(t){return t?(t.hasOwnProperty("width")&&(t.displayWidth=t.width,delete t.width),t.hasOwnProperty("height")&&(t.displayHeight=t.height,delete t.height),t.hasOwnProperty("frame")&&this.setFrame(t.frame),super.modifyPorperties(t),t.hasOwnProperty("flipX")&&this.setFlipX(t.flipX),t.hasOwnProperty("flipY")&&this.setFlipY(t.flipY),t.hasOwnProperty("tint")&&this.setTint(t.tint),t.hasOwnProperty("tintFill")&&this.setTintFill(t.tintFill),this):this}}var z=function(t){return void 0===t&&(t={}),t.u0=0,t.v0=0,t.u1=0,t.v1=0,t.x=0,t.y=0,t.width=0,t.height=0,t.flipX=!1,t.flipY=!1,t.cx=0,t.cy=0,t.cw=0,t.ch=0,t},$={webglRender:function(t,i,e,s,r,h,a,n){var o=this.frame;if(o){var l,d,c,u,p,g,v,f,m=this._width,y=this._height,w=m*this.originX,P=y*this.originY,b=this.x-s,x=this.y-r;if(this.isCropped){var O=this._crop;O.flipX===this.flipX&&O.flipY===this.flipY||o.updateCropUVs(O,this.flipX,this.flipY),l=O.u0,d=O.v0,c=O.u1,u=O.v1,v=O.width,f=O.height,p=O.x,g=O.y}else l=this.frame.u0,d=this.frame.v0,c=this.frame.u1,u=this.frame.v1,v=m,f=y,p=0,g=0;var _=1,F=1;this.flipX&&(b+=m-2*w,_=-1),this.flipY&&(x+=y-2*P,F=-1),V.applyITRS(b,x,this.rotation,this.scaleX*_,this.scaleY*F),i.multiply(V,V);var X=-w+p,Y=-P+g,D=X+v,S=Y+f,C=V.setQuad(X,Y,D,S,n),M=N(this.tint,this.alpha*e);t.batchQuad(this.parent,C[0],C[1],C[2],C[3],C[4],C[5],C[6],C[7],l,d,c,u,M,M,M,M,this.tintFill,h,a)}},canvasRender:function(t,i,e,s){var r=this.frame;if(r){t.save();var h,a,n,o,l=this._width,d=this._height,c=l*this.originX,u=d*this.originY,p=this.x-c,g=this.y-u;if(this.isCropped){var v=this._crop;v.flipX===this.flipX&&v.flipY===this.flipY||r.updateCropUVs(v,this.flipX,this.flipY),n=v.cw,o=v.ch,h=v.cx,a=v.cy}else n=r.cutWidth,o=r.cutHeight,h=r.cutX,a=r.cutY;var f=1,m=1;this.flipX&&(p+=l,f=-1),this.flipY&&(g+=d,m=-1);var y=r.source.resolution,w=n/y,P=o/y;s&&(p=Math.floor(p+.5),g=Math.floor(g+.5),w+=.5,P+=.5),t.translate(p,g),t.rotate(this.rotation),t.scale(this.scaleX*f,this.scaleY*m),t.drawImage(r.source.image,h,a,n,o,0,0,w,P),t.restore()}}};Object.assign(I.prototype,$);var E=function(t,i){"string"==typeof i&&(i={frame:i});var e=t.poolManager?t.poolManager.allocate(j):null;return null===e?e=new I(t):e.setParent(t).setActive(),e.modifyPorperties(i),t.addChild(e),e},K={_drawImage:function(t,i,e,s,r,h){E(this,{frame:i,x:e,y:s,width:r,height:h})},_drawTileSprite:function(t,i,e,s,r,h){var a=this.texture.get(i),n=a.width,o=a.height,l=r%n,d=h%o;0===l&&(l=n),0===d&&(d=o);for(var c=Math.ceil(r/n),u=Math.ceil(h/o),p=c-1,g=u-1,v=0;vi(t)));if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if(Object.getPrototypeOf(t)!==Object.prototype)return t;const e={};for(let s in t)t.hasOwnProperty(s)&&(e[s]=i(t[s]));return e}const s=Phaser.Utils.Objects.IsPlainObject,r=Phaser.Utils.Objects.GetValue;var n=function(t){return"string"==typeof t&&(t=a[t]),t};const a={scale:0,repeat:1};var o=function(t,e){return 0===t||t===this.columns.count-1||0===e||e===this.rows.count-1},h=function(){},l={_beginDraw:h,_drawImage:h,_drawTileSprite:h,_endDraw:h,setGetFrameNameCallback:function(t){return void 0===t&&(t=e),this.getFrameNameCallback=t,this},setBaseTexture:function(t,e,s,r){Array.isArray(e)&&(r=s,s=e,e=void 0),null==e&&(e="__BASE"),"number"==typeof s&&arguments.length>=6?(s=[arguments[2],void 0,arguments[3]],r=[arguments[4],void 0,arguments[5]]):void 0===s&&void 0===r&&void 0!==this.columns.data&&void 0!==this.rows.data?(s=this.columns.data,r=this.rows.data):(s=i(s),r=i(r)),this.textureKey=t,this.baseFrameName=e,this.columns.data=s,this.columns.count=s?s.length:0,this.columns.stretch=0,this.columns.minWidth=0,this.columns.scale=1,this.rows.data=r,this.rows.count=r?r.length:0,this.rows.stretch=0,this.rows.minHeight=0,this.rows.scale=1;var n=this.scene.sys.textures.get(t);if(!n)return this.clear(),this;if(!s||!r)return this.clear(),this;for(var a=n.get(e),o=a.width,h=0,l=0,d=s.length;l0?o/h:0,u=a.height,p=0;for(l=0,d=r.length;l0?0:f,x=0,l=0;for(var S=s.length;l0?0:m),m>=1&&f>=1){var P=typeof(y=this.getFrameNameCallback(l,k,e));"string"!==P&&"number"!==P||n.add(y,0,x+a.cutX,C+a.cutY,m,f)}x+=m}C+=f}return this.updateTexture(),this},updateTexture:function(){if(this.clear(),void 0===this.textureKey)return this;var t=this.scene.sys.textures.get(this.textureKey);if(!t)return this;var e,i,s,r,n,a,o,h=this.columns.minWidth*this.maxFixedPartScaleX,l=this.rows.minHeight*this.maxFixedPartScaleY,d=this.width-h,c=this.height-l,u=d>=0?this.maxFixedPartScaleX:this.width/h,p=c>=0?this.maxFixedPartScaleY:this.height/l;if(this.preserveRatio){var g=Math.min(u,p);if(u>g){var v=(u-g)*h;d>=0?d+=v:d=v,u=g}if(p>g){var f=(p-g)*l;c>=0?c+=f:c=f,p=g}}this.columns.scale=u,this.rows.scale=p,e=d>0&&this.columns.stretch>0?d/this.columns.stretch:0,i=c>0&&this.rows.stretch>0?c/this.rows.stretch:0;var m=0,y=0;this._beginDraw();for(var b=0,x=this.rows.count;b0&&o>0&&(0==(0===n.stretch&&0===r.stretch||0===this.getStretchMode(C,b)?0:1)?this._drawImage(this.textureKey,s,m,y,a,o):this._drawTileSprite(this.textureKey,s,m,y,a,o)),m+=a;y+=o}this._endDraw()},setStretchMode:function(t){return s(t)?(this.stretchMode.edge=n(r(t,"edge",0)),this.stretchMode.internal=n(r(t,"internal",0))):(t=n(t),this.stretchMode.edge=t,this.stretchMode.internal=t),this},getStretchMode:function(t,e){return o.call(this,t,e)?this.stretchMode.edge:this.stretchMode.internal},setPreserveRatio:function(t){return null==t&&(t=!0),this.preserveRatio=t,this},setMaxFixedPartScale:function(t,e){return void 0===e&&(e=t),this.maxFixedPartScaleX=t,this.maxFixedPartScaleY=e,this}};const d=Phaser.Utils.Objects.IsPlainObject,c=Phaser.Utils.Objects.GetValue;var u=function(t,e){class i extends t{constructor(t,i,s,r,n,a,o,h,l,u){if(d(i)?(i=c(u=i,"x",0),s=c(u,"y",0),r=c(u,"width",1),n=c(u,"height",1),a=c(u,"key",void 0),o=c(u,"baseFrame",void 0),h=c(u,"columns",void 0),l=c(u,"rows",void 0)):d(r)?(r=c(u=r,"width",1),n=c(u,"height",1),a=c(u,"key",void 0),o=c(u,"baseFrame",void 0),h=c(u,"columns",void 0),l=c(u,"rows",void 0)):d(a)?(a=c(u=a,"key",void 0),o=c(u,"baseFrame",void 0),h=c(u,"columns",void 0),l=c(u,"rows",void 0)):d(o)?(o=c(u=o,"baseFrame",void 0),h=c(u,"columns",void 0),l=c(u,"rows",void 0)):Array.isArray(o)?(u=l,l=h,h=o,o=c(u,"baseFrame",void 0)):d(h)&&(h=c(u=h,"columns",void 0),l=c(u,"rows",void 0)),void 0===o&&(o=c(u,"frame",void 0)),void 0===h){var p=c(u,"leftWidth",void 0),g=c(u,"rightWidth",void 0);void 0!==p&&void 0!==g&&(h=[p,void 0,g])}if(void 0===l){var v=c(u,"topHeight",void 0),f=c(u,"bottomHeight",void 0);void 0!==v&&void 0!==f&&(l=[v,void 0,f])}super(t),this.type=e,this.setPosition(i,s).setSize(r,n).setOrigin(.5,.5),this.columns={},this.rows={},this.stretchMode={},this._tileSprite=void 0,this._image=void 0,this.setGetFrameNameCallback(c(u,"getFrameNameCallback",void 0)),this.setStretchMode(c(u,"stretchMode",0)),this.setPreserveRatio(c(u,"preserveRatio",!0));var m=c(u,"maxFixedPartScale",1),y=c(u,"maxFixedPartScaleX",m),b=c(u,"maxFixedPartScaleY",void 0);this.setMaxFixedPartScale(y,b),this.setBaseTexture(a,o,h,l)}get minWidth(){return this.columns.minWidth}get minHeight(){return this.rows.minHeight}get fixedPartScaleX(){return this.columns.scale}get fixedPartScaleY(){return this.rows.scale}resize(t,e){return this.width===t&&this.height===e||(super.resize?super.resize(t,e):super.setSize(t,e),this.updateTexture()),this}get leftWidth(){return this.columns.data[0]}get rightWidth(){return this.columns.data[this.columns.count-1]}get topHeight(){return this.rows.data[0]}get bottomHeight(){return this.rows.data[this.rows.count-1]}}return Object.assign(i.prototype,l),i};const p=Phaser.Game;var g=function(t){return t instanceof p};const v=Phaser.Scene;var f=function(t){return t instanceof v},m=function(t){return null==t||"object"!=typeof t?null:g(t)?t:g(t.game)?t.game:f(t)?t.sys.game:f(t.scene)?t.scene.sys.game:void 0};const y=Phaser.GameObjects;var b=void 0,x=function(t,e){if(b||(b={},m(t).events.once("destroy",(function(){for(var t in b)b[t].destroy();b=void 0}))),!b.hasOwnProperty(e)){var i=m(t).scene.systemScene;(t=new y[e](i)).setOrigin(0),b[e]=t}return b[e]};const C=Phaser.GameObjects.RenderTexture;let k=class extends(u(C,"rexNinePatch")){};var w={_drawImage:function(t,e,i,s,r,n){var a=x(this,"Image").setTexture(t,e).setDisplaySize(r,n);this.draw(a,i,s)},_drawTileSprite:function(t,e,i,s,r,n){var a=x(this,"TileSprite").setTexture(t,e).setSize(r,n);this.draw(a,i,s)}};Object.assign(k.prototype,w);var S=function(t){return null==t||""===t||0===t.length},P=function(t,e,i,s){if(void 0===s&&(s="."),"object"==typeof t){if(S(e)){if(null==i)return;"object"==typeof i&&(t=i)}else{"string"==typeof e&&(e=e.split(s));var r=e.pop(),n=function(t,e,i){var s=t;if(S(e));else{var r;"string"==typeof e&&(e=e.split("."));for(var n=0,a=e.length;n0?this.items.pop():null}push(t){return this.items.push(t),this}pushMultiple(t){return this.items.push.apply(this.items,t),t.length=0,this}clear(){return this.items.length=0,this}}const D=Phaser.Utils.Objects.GetValue;var A={};let j=class{constructor(t){this.pools=D(t,"pools",A)}destroy(){this.pools=void 0}free(t){if(!this.pools)return this;var e=t.type;return this.pools.hasOwnProperty(e)||(this.pools[e]=new I),this.pools[e].push(t),t.onFree(),this}freeMultiple(t){if(!this.pools)return this;for(var e=0,i=t.length;e0},N=function(t,e){return t._depth-e._depth};const $=Phaser.GameObjects.Components;Phaser.Class.mixin(H,[$.Alpha,$.BlendMode,$.ComputedSize,$.Depth,$.GetBounds,$.Mask,$.Origin,$.Pipeline,$.PostPipeline,$.ScrollFactor,$.Transform,$.Visible,M,B]);const K="image";var J=function(t,e,i){if(!t||"number"==typeof t)return i;if("string"==typeof e){if(t.hasOwnProperty(e))return t[e];if(-1===e.indexOf("."))return i;e=e.split(".")}for(var s=e,r=t,n=i,a=0;a0&&!ot(t)&&(t=this.parent.texture.get(t)),this.frame=t,t?(this._width=t.realWidth,this._height=t.realHeight):(this._width=0,this._height=0),this}setFlipX(t){return void 0===t&&(t=!0),this.flipX=t,this}setFlipY(t){return void 0===t&&(t=!0),this.flipY=t,this}resetFlip(){return this.flipX=!1,this.flipY=!1,this}get tint(){return void 0===this._tint?this.parent.tint:this._tint}set tint(t){this._tint=t}setTint(t){return this.tint=t,this.tintFill=!1,this}setTintFill(t){return this.tint=t,this.tintFill=!0,this}clearTint(){return this.setTint(16777215),this}resetTint(){return this.tint=void 0,this.tintFill=void 0,this}get tintFill(){return void 0===this._tintFill?this.parent.tintFill:this._tintFill}set tintFill(t){this._tintFill=t}setCrop(t,e,i,s){return void 0===t?(this.isCropped=!1,this):this.frame?0===t&&0===e&&i===this._width&&s===this._height?(this.isCropped=!1,this):(this.frame.setCropUVs(this._crop,t,e,i,s,this.flipX,this.flipY),this.isCropped=!0,this):this}reset(){return super.reset(),this.resetFlip().resetTint().setFrame().setCrop(),this}modifyPorperties(t){return t?(t.hasOwnProperty("width")&&(t.displayWidth=t.width,delete t.width),t.hasOwnProperty("height")&&(t.displayHeight=t.height,delete t.height),t.hasOwnProperty("frame")&&this.setFrame(t.frame),super.modifyPorperties(t),t.hasOwnProperty("flipX")&&this.setFlipX(t.flipX),t.hasOwnProperty("flipY")&&this.setFlipY(t.flipY),t.hasOwnProperty("tint")&&this.setTint(t.tint),t.hasOwnProperty("tintFill")&&this.setTintFill(t.tintFill),this):this}};var lt=function(t){return void 0===t&&(t={}),t.u0=0,t.v0=0,t.u1=0,t.v1=0,t.x=0,t.y=0,t.width=0,t.height=0,t.flipX=!1,t.flipY=!1,t.cx=0,t.cy=0,t.cw=0,t.ch=0,t},dt={webglRender:function(t,e,i,s,r,n,a,o){var h=this.frame;if(h){var l,d,c,u,p,g,v,f,m=this._width,y=this._height,b=m*this.originX,x=y*this.originY,C=this.x-s,k=this.y-r;if(this.isCropped){var w=this._crop;w.flipX===this.flipX&&w.flipY===this.flipY||h.updateCropUVs(w,this.flipX,this.flipY),l=w.u0,d=w.v0,c=w.u1,u=w.v1,v=w.width,f=w.height,p=w.x,g=w.y}else l=this.frame.u0,d=this.frame.v0,c=this.frame.u1,u=this.frame.v1,v=m,f=y,p=0,g=0;var S=1,P=1;this.flipX&&(C+=m-2*b,S=-1),this.flipY&&(k+=y-2*x,P=-1),at.applyITRS(C,k,this.rotation,this.scaleX*S,this.scaleY*P),e.multiply(at,at);var T=-b+p,O=-x+g,M=T+v,E=O+f,_=at.setQuad(T,O,M,E,o),R=nt(this.tint,this.alpha*i);t.batchQuad(this.parent,_[0],_[1],_[2],_[3],_[4],_[5],_[6],_[7],l,d,c,u,R,R,R,R,this.tintFill,n,a)}},canvasRender:function(t,e,i,s){t.save();var r=this._width,n=this._height,a=r*this.originX,o=n*this.originY,h=this.x-a,l=this.y-o,d=1,c=1;this.flipX&&(h+=r,d=-1),this.flipY&&(l+=n,c=-1),s&&(h=Math.round(h),l=Math.round(l)),t.translate(h,l),t.rotate(this.rotation),t.scale(this.scaleX*d,this.scaleY*c);var u=this.frame;t.drawImage(u.source.image,u.cutX,u.cutY,r,n,0,0,r,n),t.restore()}};Object.assign(ht.prototype,dt);var ct=function(t,e){"string"==typeof e&&(e={frame:e});var i=t.poolManager?t.poolManager.allocate(K):null;return null===i?i=new ht(t):i.setParent(t).setActive(),i.modifyPorperties(e),t.addChild(i),i},ut={_drawImage:function(t,e,i,s,r,n){ct(this,{frame:e,x:i,y:s,width:r,height:n})},_drawTileSprite:function(t,e,i,s,r,n){for(var a=this.texture.get(e),o=a.width,h=a.height,l=r%o,d=n%h,c=0!==l,u=0!==d,p=Math.ceil(r/o),g=Math.ceil(n/h),v=p-1,f=g-1,m=0;m>>16,o=(65280&r)>>>8,h=255&r;t.fillStyle="rgba("+a+","+o+","+h+","+n+")"},xt=function(t,e,i,s){var r=i||e.strokeColor,n=s||e.strokeAlpha,a=(16711680&r)>>>16,o=(65280&r)>>>8,h=255&r;t.strokeStyle="rgba("+a+","+o+","+h+","+n+")",t.lineWidth=e.lineWidth};const Ct=Phaser.Renderer.Canvas.SetTransform;var kt={renderWebGL:function(t,e,i,s){e.dirty&&(e.updateData(),e.dirty=!1),i.addToRenderList(e);var r=t.pipelines.set(e.pipeline),n=yt(e,i,s),a=r.calcMatrix.copyFrom(n.calc),o=e._displayOriginX,h=e._displayOriginY,l=i.alpha*e.alpha;t.pipelines.preBatch(e),e.isFilled&&vt(r,a,e,l,o,h),e.isStroked&&mt(r,e,l,o,h),t.pipelines.postBatch(e)},renderCanvas:function(t,e,i,s){e.dirty&&(e.updateData(),e.dirty=!1),i.addToRenderList(e);var r=t.currentContext;if(Ct(t,r,e,i,s)){var n=e._displayOriginX,a=e._displayOriginY,o=e.pathData,h=o.length-1,l=o[0]-n,d=o[1]-a;r.beginPath(),r.moveTo(l,d),e.closePath||(h-=2);for(var c=2;c0}get fillAlpha(){return this._fillAlpha}set fillAlpha(t){this._fillAlpha=t,this.isFilled=t>0&&null!=this._fillColor}setFillStyle(t,e){return void 0===e&&(e=1),this.fillColor=t,this.fillAlpha=e,this}get strokeColor(){return this._strokeColor}set strokeColor(t){this._strokeColor=t,this.isStroked=null!=t&&this._strokeAlpha>0&&this._lineWidth>0}get strokeAlpha(){return this._strokeAlpha}set strokeAlpha(t){this._strokeAlpha=t,this.isStroked=t>0&&null!=this._strokeColor&&this._lineWidth>0}get lineWidth(){return this._lineWidth}set lineWidth(t){this._lineWidth=t,this.isStroked=t>0&&null!=this._strokeColor}setStrokeStyle(t,e,i){return void 0===i&&(i=1),this.lineWidth=t,this.strokeColor=e,this.strokeAlpha=i,this}updateData(){return this}get width(){return this.geom.width}set width(t){this.resize(t,this.height)}get height(){return this.geom.height}set height(t){this.resize(this.width,t)}setSize(t,e){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}}Object.assign(St.prototype,kt);const Pt=Phaser.Utils.Objects.GetValue;let Tt=class{constructor(t,e,i,s,r){void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===s&&(s=0),void 0===r&&(r=0),this.cornerRadius={},this._width=0,this._height=0,this.setTo(t,e,i,s,r)}setTo(t,e,i,s,r){return this.setPosition(t,e),this.setRadius(r),this.setSize(i,s),this}setPosition(t,e){return this.x=t,this.y=e,this}setRadius(t){return void 0===t&&(t=0),this.radius=t,this}setSize(t,e){return this.width=t,this.height=e,this}get minWidth(){var t=this.cornerRadius;return Math.max(t.tl.x+t.tr.x,t.bl.x+t.br.x)}get minHeight(){var t=this.cornerRadius;return Math.max(t.tl.y+t.bl.y,t.tr.y+t.br.y)}get width(){return this._width}set width(t){null==t&&(t=0),this._width=Math.max(t,this.minWidth)}get height(){return this._height}set height(t){null==t&&(t=0),this._height=Math.max(t,this.minHeight)}get radius(){var t=this.cornerRadius;return Math.max(t.tl.x,t.tl.y,t.tr.x,t.tr.y,t.bl.x,t.bl.y,t.br.x,t.br.y)}set radius(t){var e,i;"number"==typeof t?(e=t,i=t):(e=Pt(t,"x",0),i=Pt(t,"y",0));var s=this.cornerRadius;s.tl=Ot(Pt(t,"tl",void 0),e,i),s.tr=Ot(Pt(t,"tr",void 0),e,i),s.bl=Ot(Pt(t,"bl",void 0),e,i),s.br=Ot(Pt(t,"br",void 0),e,i)}get radiusTL(){var t=this.cornerRadius.tl;return Math.max(t.x,t.y)}set radiusTL(t){Mt(this.cornerRadius.tl,t)}get radiusTR(){var t=this.cornerRadius.tr;return Math.max(t.x,t.y)}set radiusTR(t){Mt(this.cornerRadius.tr,t)}get radiusBL(){var t=this.cornerRadius.bl;return Math.max(t.x,t.y)}set radiusBL(t){Mt(this.cornerRadius.bl,t)}get radiusBR(){var t=this.cornerRadius.br;return Math.max(t.x,t.y)}set radiusBR(t){Mt(this.cornerRadius.br,t)}};var Ot=function(t,e,i){return void 0===t?t={x:e,y:i}:"number"==typeof t&&(t={x:t,y:t}),Et(t),t},Mt=function(t,e){"number"==typeof e?(t.x=e,t.y=e):(t.x=Pt(e,"x",0),t.y=Pt(e,"y",0)),Et(t)},Et=function(t){t.convex=t.x>=0||t.y>=0,t.x=Math.abs(t.x),t.y=Math.abs(t.y)},_t=function(t){return t.x>0&&t.y>0},Rt=function(t,e,i){var s=i.length;if(s>=2){var r=i[s-2],n=i[s-1];if(t===r&&e===n)return i}return i.push(t,e),i};const Lt=Phaser.Math.DegToRad;var Bt=function(t,e,i,s,r,n,a,o,h){a&&n>r?n-=360:!a&&n=p?1:s/p,f=r>=g?1:r/g,m=u.cornerRadius;t.save(),t.beginPath(),t.translate(e,i),o=m.tl,ee(o)?(h=o.x*v,l=o.y*f,te(o)?ie(t,h,l,h,l,180,270,!1,a):ie(t,0,0,h,l,90,0,!0,a),d=0,c=l):(t.lineTo(0,0),d=0,c=0),o=m.tr,ee(o)?(h=o.x*v,l=o.y*f,te(o)?ie(t,s-h,l,h,l,270,360,!1,a):ie(t,s,0,h,l,180,90,!0,a)):t.lineTo(s,0),o=m.br,ee(o)?(h=o.x*v,l=o.y*f,te(o)?ie(t,s-h,r-l,h,l,0,90,!1,a):ie(t,s,r,h,l,270,180,!0,a)):t.lineTo(s,r),o=m.bl,ee(o)?(h=o.x*v,l=o.y*f,te(o)?ie(t,h,r-l,h,l,90,180,!1,a):ie(t,0,r,h,l,360,270,!0,a)):t.lineTo(0,r),t.lineTo(d,c),t.closePath(),t.restore()},te=function(t){return!t.hasOwnProperty("convex")||t.convex},ee=function(t){return t.x>0&&t.y>0},ie=function(t,e,i,s,r,n,a,o,h){if(o&&a>n?a-=360:!o&&a0&&(e.strokeStyle=h,e.lineWidth=l,e.stroke())}(t.canvas,t.context,d,d,h,l,r,e,i,s,n,a,o)}},re=function(){se(this,this.fillStyle,this.strokeStyle,this.lineWidth,this.radius,this.fillColor2,this.isHorizontalGradient,this.iteration)};const ne=Phaser.Utils.Objects.GetValue;let ae=class extends $t{constructor(t,e,i,s,r,n,a,o,h,l,d,c){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=1),void 0===r&&(r=s),void 0===n&&(n=0),void 0===c&&(c=1),super(t,e,i,s,r,c),this.type="rexRoundRectangleCanvas";var u=ne(n,"radius",n),p=ne(n,"iteration",void 0);this.setRadius(u),this.setIteration(p),this.setFillStyle(a,l,d),this.setStrokeStyle(o,h)}get radius(){return this._radius}set radius(t){this.dirty|=this._radius!=t,this._radius=t}setRadius(t){return this.radius=t,this}get iteration(){return this._iteration}set iteration(t){this.dirty|=this._iteration!=t,this._iteration=t}setIteration(t){return this.iteration=t,this}get fillStyle(){return this._fillStyle}set fillStyle(t){t=qt(t,this.canvas,this.context),this.dirty|=this._fillStyle!=t,this._fillStyle=t}get fillColor2(){return this._fillColor2}set fillColor2(t){t=qt(t,this.canvas,this.context),this.dirty|=this._fillColor2!=t,this._fillColor2=t}get isHorizontalGradient(){return this._isHorizontalGradient}set isHorizontalGradient(t){this.dirty|=this._isHorizontalGradient!=t,this._isHorizontalGradient=t}setFillStyle(t,e,i){return void 0===i&&(i=!0),this.fillStyle=t,this.fillColor2=e,this.isHorizontalGradient=i,this}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){t=qt(t,this.canvas,this.context),this.dirty|=this._strokeStyle!=t,this._strokeStyle=t}get lineWidth(){return this._lineWidth}set lineWidth(t){this.dirty|=this._lineWidth!=t,this._lineWidth=t}setStrokeStyle(t,e){return this.strokeStyle=t,this.lineWidth=e,this}updateTexture(){return super.updateTexture((function(){this.clear(),re.call(this)}),this),this}};t.register("roundRectangleCanvas",(function(t,e,i,s,r,n,a,o,h,l){var d=new ae(this.scene,t,e,i,s,r,n,a,o,h,l);return this.scene.add.existing(d),d})),P(window,"RexPlugins.UI.RoundRectangleCanvas",ae);var oe=function(t,e){if(!t)return!1;if(t.hasOwnProperty(e))return!0;for(;t;){if(Object.getOwnPropertyDescriptor(t,e))return!0;t=t.__proto__}return!1},he=function(t,e,i){e&&!oe(t,`${e}X`)&&(Object.defineProperty(t,`${e}X`,{get:function(){return i.x},set:function(e){i.x=e,t.dirty=!0}}),Object.defineProperty(t,`${e}Y`,{get:function(){return i.y},set:function(e){i.y=e,t.dirty=!0}}),Object.defineProperty(t,`${e}T`,{get:function(){return i.t},set:function(e){i.t=e,t.dirty=!0}}))},le={setTLPosition(t,e){return this.geom.setTLPosition(t,e),this.dirty=!0,this},setTRPosition(t,e){return this.geom.setTRPosition(t,e),this.dirty=!0,this},setBLPosition(t,e){return this.geom.setBLPosition(t,e),this.dirty=!0,this},setBRPosition(t,e){return this.geom.setBRPosition(t,e),this.dirty=!0,this},resetCornerPosition(){return this.geom.resetCornerPosition(),this.dirty=!0,this},insertTopSidePoint(t,e,i,s){var r=this.geom.topSidePoints;if(Array.isArray(t))for(var n,a=0,o=(r=t).length;a=0;f--)y=g[f],b=ge(d,h,y.t)+y.x,x=ge(c,l,y.t)+y.y,Rt(b,x,e);for(Rt(d,c,e),me(v),f=v.length-1;f>=0;f--)y=v[f],b=ge(r,d,y.t)+y.x,x=ge(n,c,y.t)+y.y,Rt(b,x,e);return e.push(e[0],e[1]),this.pathIndexes=ve(e),this}get tlx(){return this.geom.tlx}set tlx(t){this.geom.tlx=t,this.dirty=!0}get tly(){return this.geom.tly}set tly(t){this.geom.tly=t,this.dirty=!0}get trx(){return this.geom.trx}set trx(t){this.geom.trx=t,this.dirty=!0}get try(){return this.geom.try}set try(t){this.geom.try=t,this.dirty=!0}get blx(){return this.geom.blx}set blx(t){this.geom.blx=t,this.dirty=!0}get bly(){return this.geom.bly}set bly(t){this.geom.bly=t,this.dirty=!0}get brx(){return this.geom.brx}set brx(t){this.geom.brx=t,this.dirty=!0}get bry(){return this.geom.bry}set bry(t){this.geom.bry=t,this.dirty=!0}get leftSidePoints(){return this.geom.leftSidePoints}get topSidePoints(){return this.geom.topSidePoints}get bottomSidePoints(){return this.geom.bottomSidePoints}get rightSidePoints(){return this.geom.rightSidePoints}}var me=function(t){t.length<=1||t.sort((function(t,e){return t.t-e.t}))};Object.assign(fe.prototype,le),t.register("QuadShape",(function(t,e,i,s,r,n){var a=new fe(this.scene,t,e,i,s,r,n);return this.scene.add.existing(a),a})),P(window,"RexPlugins.UI.QuadShape",fe);var ye=Phaser.Renderer.WebGL.Utils,be={renderWebGL:function(t,e,i,s){if(0!==e.width&&0!==e.height){i.addToRenderList(e);var r=e.frame,n=r.width,a=r.height,o=ye.getTintAppendFloatAlpha,h=t.pipelines.set(e.pipeline,e),l=h.setTexture2D(r.glTexture,e);t.pipelines.preBatch(e),h.batchTexture(e,r.glTexture,n,a,e.x,e.y,n/e.style.resolution,a/e.style.resolution,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,n,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,l),t.pipelines.postBatch(e)}},renderCanvas:function(t,e,i,s){0!==e.width&&0!==e.height&&(i.addToRenderList(e),t.batchSprite(e,e.frame,i,s))}};const xe=Phaser.Display.Canvas.CanvasPool;F();const Ce=Phaser.GameObjects.GameObject;class ke extends Ce{setStyle(t){return this.style.setStyle(t)}setFont(t){return this.style.setFont(t)}setFontFamily(t){return this.style.setFontFamily(t)}setFontSize(t){return this.style.setFontSize(t)}setFontStyle(t){return this.style.setFontStyle(t)}setTestString(t){return this.style.setTestString(t)}setFixedSize(t,e){return this.style.setFixedSize(t,e)}setBackgroundColor(t,e,i){return this.style.setBackgroundColor(t,e,i)}setBackgroundStrokeColor(t,e){return this.style.setBackgroundStrokeColor(t,e)}setBackgroundCornerRadius(t,e){return this.style.setBackgroundCornerRadius(t,e)}setFill(t){return this.style.setFill(t)}setColor(t){return this.style.setColor(t)}setStroke(t,e){return this.style.setStroke(t,e)}setShadow(t,e,i,s,r,n){return this.style.setShadow(t,e,i,s,r,n)}setShadowOffset(t,e){return this.style.setShadowOffset(t,e)}setShadowColor(t){return this.style.setShadowColor(t)}setShadowBlur(t){return this.style.setShadowBlur(t)}setShadowStroke(t){return this.style.setShadowStroke(t)}setShadowFill(t){return this.style.setShadowFill(t)}setUnderline(t,e,i){return this.style.setUnderline(t,e,i)}setUnderlineColor(t){return this.style.setUnderlineColor(t)}setUnderlineThickness(t){return this.style.setUnderlineThickness(t)}setUnderlineOffset(t){return this.style.setUnderlineOffset(t)}setStrikethrough(t,e,i){return this.style.setStrikethrough(t,e,i)}setStrikethroughColor(t){return this.style.setStrikethroughColor(t)}setStrikethroughThickness(t){return this.style.setStrikethroughThickness(t)}setStrikethroughOffset(t){return this.style.setStrikethroughOffset(t)}setWrapMode(t){return this.style.setWrapMode(t)}setWrapWidth(t){return this.style.setWrapWidth(t)}setWordWrapWidth(t){return this.style.setWrapWidth(t)}setAlign(t){return this.style.setHAlign(t)}setHAlign(t){return this.style.setHAlign(t)}setVAlign(t){return this.style.setVAlign(t)}get lineSpacing(){return this.style.lineSpacing}set lineSpacing(t){this.style.lineSpacing=t}setLineSpacing(t){return this.style.lineSpacing=t,this.updateText(!0),this}setXOffset(t){return this.style.setXOffset(t)}setMaxLines(t){return this.style.setMaxLines(t)}setResolution(t){return this.style.setResolution(t)}getTextMetrics(){return this.style.getTextMetrics()}setTextMetrics(t,e){return this.style.setTextMetrics(t,e)}measureTextMargins(t,e){return function(t,e,i){void 0===i&&(i={});var s=xe.create(this),r=s.getContext("2d",{willReadFrequently:!0});t.syncFont(s,r);var n=r.measureText(e),a=Math.ceil(n.width*t.baselineX),o=a,h=2*o;if(o=o*t.baselineY|0,s.width=a,s.height=h,r.fillStyle="#f00",r.fillRect(0,0,a,h),r.font=t._font,r.textBaseline="alphabetic",r.fillStyle="#000",r.fillText(t.testString,0,o),i.left=0,0===a||0===h||!r.getImageData(0,0,a,h))return xe.remove(s),i;for(var l=r.getImageData(0,0,a,h).data,d=!1,c=0;ci(t)));if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if(Object.getPrototypeOf(t)!==Object.prototype)return t;const e={};for(let s in t)t.hasOwnProperty(s)&&(e[s]=i(t[s]));return e}const s=Phaser.Utils.Objects.IsPlainObject,r=Phaser.Utils.Objects.GetValue;var n=function(t){return"string"==typeof t&&(t=a[t]),t};const a={scale:0,repeat:1};var o=function(t,e){return 0===t||t===this.columns.count-1||0===e||e===this.rows.count-1},h=function(){},l={_beginDraw:h,_drawImage:h,_drawTileSprite:h,_endDraw:h,setGetFrameNameCallback:function(t){return void 0===t&&(t=e),this.getFrameNameCallback=t,this},setBaseTexture:function(t,e,s,r){Array.isArray(e)&&(r=s,s=e,e=void 0),null==e&&(e="__BASE"),"number"==typeof s&&arguments.length>=6?(s=[arguments[2],void 0,arguments[3]],r=[arguments[4],void 0,arguments[5]]):void 0===s&&void 0===r&&void 0!==this.columns.data&&void 0!==this.rows.data?(s=this.columns.data,r=this.rows.data):(s=i(s),r=i(r)),this.textureKey=t,this.baseFrameName=e,this.columns.data=s,this.columns.count=s?s.length:0,this.columns.stretch=0,this.columns.minWidth=0,this.columns.scale=1,this.rows.data=r,this.rows.count=r?r.length:0,this.rows.stretch=0,this.rows.minHeight=0,this.rows.scale=1;var n=this.scene.sys.textures.get(t);if(!n)return this.clear(),this;if(!s||!r)return this.clear(),this;for(var a=n.get(e),o=a.width,h=0,l=0,d=s.length;l0?o/h:0,u=a.height,p=0;for(l=0,d=r.length;l0?0:f,x=0,l=0;for(var S=s.length;l0?0:m),m>=1&&f>=1){var P=typeof(y=this.getFrameNameCallback(l,k,e));"string"!==P&&"number"!==P||n.add(y,0,x+a.cutX,C+a.cutY,m,f)}x+=m}C+=f}return this.updateTexture(),this},updateTexture:function(){if(this.clear(),void 0===this.textureKey)return this;var t=this.scene.sys.textures.get(this.textureKey);if(!t)return this;var e,i,s,r,n,a,o,h=this.columns.minWidth*this.maxFixedPartScaleX,l=this.rows.minHeight*this.maxFixedPartScaleY,d=this.width-h,c=this.height-l,u=d>=0?this.maxFixedPartScaleX:this.width/h,p=c>=0?this.maxFixedPartScaleY:this.height/l;if(this.preserveRatio){var g=Math.min(u,p);if(u>g){var v=(u-g)*h;d>=0?d+=v:d=v,u=g}if(p>g){var f=(p-g)*l;c>=0?c+=f:c=f,p=g}}this.columns.scale=u,this.rows.scale=p,e=d>0&&this.columns.stretch>0?d/this.columns.stretch:0,i=c>0&&this.rows.stretch>0?c/this.rows.stretch:0;var m=0,y=0;this._beginDraw();for(var b=0,x=this.rows.count;b0&&o>0&&(0==(0===n.stretch&&0===r.stretch||0===this.getStretchMode(C,b)?0:1)?this._drawImage(this.textureKey,s,m,y,a,o):this._drawTileSprite(this.textureKey,s,m,y,a,o)),m+=a;y+=o}this._endDraw()},setStretchMode:function(t){return s(t)?(this.stretchMode.edge=n(r(t,"edge",0)),this.stretchMode.internal=n(r(t,"internal",0))):(t=n(t),this.stretchMode.edge=t,this.stretchMode.internal=t),this},getStretchMode:function(t,e){return o.call(this,t,e)?this.stretchMode.edge:this.stretchMode.internal},setPreserveRatio:function(t){return null==t&&(t=!0),this.preserveRatio=t,this},setMaxFixedPartScale:function(t,e){return void 0===e&&(e=t),this.maxFixedPartScaleX=t,this.maxFixedPartScaleY=e,this}};const d=Phaser.Utils.Objects.IsPlainObject,c=Phaser.Utils.Objects.GetValue;var u=function(t,e){class i extends t{constructor(t,i,s,r,n,a,o,h,l,u){if(d(i)?(i=c(u=i,"x",0),s=c(u,"y",0),r=c(u,"width",1),n=c(u,"height",1),a=c(u,"key",void 0),o=c(u,"baseFrame",void 0),h=c(u,"columns",void 0),l=c(u,"rows",void 0)):d(r)?(r=c(u=r,"width",1),n=c(u,"height",1),a=c(u,"key",void 0),o=c(u,"baseFrame",void 0),h=c(u,"columns",void 0),l=c(u,"rows",void 0)):d(a)?(a=c(u=a,"key",void 0),o=c(u,"baseFrame",void 0),h=c(u,"columns",void 0),l=c(u,"rows",void 0)):d(o)?(o=c(u=o,"baseFrame",void 0),h=c(u,"columns",void 0),l=c(u,"rows",void 0)):Array.isArray(o)?(u=l,l=h,h=o,o=c(u,"baseFrame",void 0)):d(h)&&(h=c(u=h,"columns",void 0),l=c(u,"rows",void 0)),void 0===o&&(o=c(u,"frame",void 0)),void 0===h){var p=c(u,"leftWidth",void 0),g=c(u,"rightWidth",void 0);void 0!==p&&void 0!==g&&(h=[p,void 0,g])}if(void 0===l){var v=c(u,"topHeight",void 0),f=c(u,"bottomHeight",void 0);void 0!==v&&void 0!==f&&(l=[v,void 0,f])}super(t),this.type=e,this.setPosition(i,s).setSize(r,n).setOrigin(.5,.5),this.columns={},this.rows={},this.stretchMode={},this._tileSprite=void 0,this._image=void 0,this.setGetFrameNameCallback(c(u,"getFrameNameCallback",void 0)),this.setStretchMode(c(u,"stretchMode",0)),this.setPreserveRatio(c(u,"preserveRatio",!0));var m=c(u,"maxFixedPartScale",1),y=c(u,"maxFixedPartScaleX",m),b=c(u,"maxFixedPartScaleY",void 0);this.setMaxFixedPartScale(y,b),this.setBaseTexture(a,o,h,l)}get minWidth(){return this.columns.minWidth}get minHeight(){return this.rows.minHeight}get fixedPartScaleX(){return this.columns.scale}get fixedPartScaleY(){return this.rows.scale}resize(t,e){return this.width===t&&this.height===e||(super.resize?super.resize(t,e):super.setSize(t,e),this.updateTexture()),this}get leftWidth(){return this.columns.data[0]}get rightWidth(){return this.columns.data[this.columns.count-1]}get topHeight(){return this.rows.data[0]}get bottomHeight(){return this.rows.data[this.rows.count-1]}}return Object.assign(i.prototype,l),i};const p=Phaser.Game;var g=function(t){return t instanceof p};const v=Phaser.Scene;var f=function(t){return t instanceof v},m=function(t){return null==t||"object"!=typeof t?null:g(t)?t:g(t.game)?t.game:f(t)?t.sys.game:f(t.scene)?t.scene.sys.game:void 0};const y=Phaser.GameObjects;var b=void 0,x=function(t,e){if(b||(b={},m(t).events.once("destroy",(function(){for(var t in b)b[t].destroy();b=void 0}))),!b.hasOwnProperty(e)){var i=m(t).scene.systemScene;(t=new y[e](i)).setOrigin(0),b[e]=t}return b[e]};const C=Phaser.GameObjects.RenderTexture;let k=class extends(u(C,"rexNinePatch")){};var w={_drawImage:function(t,e,i,s,r,n){var a=x(this,"Image").setTexture(t,e).setDisplaySize(r,n);this.draw(a,i,s)},_drawTileSprite:function(t,e,i,s,r,n){var a=x(this,"TileSprite").setTexture(t,e).setSize(r,n);this.draw(a,i,s)}};Object.assign(k.prototype,w);var S=function(t){return null==t||""===t||0===t.length},P=function(t,e,i,s){if(void 0===s&&(s="."),"object"==typeof t){if(S(e)){if(null==i)return;"object"==typeof i&&(t=i)}else{"string"==typeof e&&(e=e.split(s));var r=e.pop(),n=function(t,e,i){var s=t;if(S(e));else{var r;"string"==typeof e&&(e=e.split("."));for(var n=0,a=e.length;n0?this.items.pop():null}push(t){return this.items.push(t),this}pushMultiple(t){return this.items.push.apply(this.items,t),t.length=0,this}clear(){return this.items.length=0,this}}const D=Phaser.Utils.Objects.GetValue;var A={};let j=class{constructor(t){this.pools=D(t,"pools",A)}destroy(){this.pools=void 0}free(t){if(!this.pools)return this;var e=t.type;return this.pools.hasOwnProperty(e)||(this.pools[e]=new I),this.pools[e].push(t),t.onFree(),this}freeMultiple(t){if(!this.pools)return this;for(var e=0,i=t.length;e0},N=function(t,e){return t._depth-e._depth};const $=Phaser.GameObjects.Components;Phaser.Class.mixin(H,[$.Alpha,$.BlendMode,$.ComputedSize,$.Depth,$.GetBounds,$.Mask,$.Origin,$.Pipeline,$.PostPipeline,$.ScrollFactor,$.Transform,$.Visible,M,B]);const K="image";var J=function(t,e,i){if(!t||"number"==typeof t)return i;if("string"==typeof e){if(t.hasOwnProperty(e))return t[e];if(-1===e.indexOf("."))return i;e=e.split(".")}for(var s=e,r=t,n=i,a=0;a0&&!ot(t)&&(t=this.parent.texture.get(t)),this.frame=t,t?(this._width=t.realWidth,this._height=t.realHeight):(this._width=0,this._height=0),this}setFlipX(t){return void 0===t&&(t=!0),this.flipX=t,this}setFlipY(t){return void 0===t&&(t=!0),this.flipY=t,this}resetFlip(){return this.flipX=!1,this.flipY=!1,this}get tint(){return void 0===this._tint?this.parent.tint:this._tint}set tint(t){this._tint=t}setTint(t){return this.tint=t,this.tintFill=!1,this}setTintFill(t){return this.tint=t,this.tintFill=!0,this}clearTint(){return this.setTint(16777215),this}resetTint(){return this.tint=void 0,this.tintFill=void 0,this}get tintFill(){return void 0===this._tintFill?this.parent.tintFill:this._tintFill}set tintFill(t){this._tintFill=t}setCrop(t,e,i,s){return void 0===t?(this.isCropped=!1,this):this.frame?0===t&&0===e&&i===this._width&&s===this._height?(this.isCropped=!1,this):(this.frame.setCropUVs(this._crop,t,e,i,s,this.flipX,this.flipY),this.isCropped=!0,this):this}reset(){return super.reset(),this.resetFlip().resetTint().setFrame().setCrop(),this}modifyPorperties(t){return t?(t.hasOwnProperty("width")&&(t.displayWidth=t.width,delete t.width),t.hasOwnProperty("height")&&(t.displayHeight=t.height,delete t.height),t.hasOwnProperty("frame")&&this.setFrame(t.frame),super.modifyPorperties(t),t.hasOwnProperty("flipX")&&this.setFlipX(t.flipX),t.hasOwnProperty("flipY")&&this.setFlipY(t.flipY),t.hasOwnProperty("tint")&&this.setTint(t.tint),t.hasOwnProperty("tintFill")&&this.setTintFill(t.tintFill),this):this}};var lt=function(t){return void 0===t&&(t={}),t.u0=0,t.v0=0,t.u1=0,t.v1=0,t.x=0,t.y=0,t.width=0,t.height=0,t.flipX=!1,t.flipY=!1,t.cx=0,t.cy=0,t.cw=0,t.ch=0,t},dt={webglRender:function(t,e,i,s,r,n,a,o){var h=this.frame;if(h){var l,d,c,u,p,g,v,f,m=this._width,y=this._height,b=m*this.originX,x=y*this.originY,C=this.x-s,k=this.y-r;if(this.isCropped){var w=this._crop;w.flipX===this.flipX&&w.flipY===this.flipY||h.updateCropUVs(w,this.flipX,this.flipY),l=w.u0,d=w.v0,c=w.u1,u=w.v1,v=w.width,f=w.height,p=w.x,g=w.y}else l=this.frame.u0,d=this.frame.v0,c=this.frame.u1,u=this.frame.v1,v=m,f=y,p=0,g=0;var S=1,P=1;this.flipX&&(C+=m-2*b,S=-1),this.flipY&&(k+=y-2*x,P=-1),at.applyITRS(C,k,this.rotation,this.scaleX*S,this.scaleY*P),e.multiply(at,at);var T=-b+p,O=-x+g,M=T+v,E=O+f,_=at.setQuad(T,O,M,E,o),R=nt(this.tint,this.alpha*i);t.batchQuad(this.parent,_[0],_[1],_[2],_[3],_[4],_[5],_[6],_[7],l,d,c,u,R,R,R,R,this.tintFill,n,a)}},canvasRender:function(t,e,i,s){var r=this.frame;if(r){t.save();var n,a,o,h,l=this._width,d=this._height,c=l*this.originX,u=d*this.originY,p=this.x-c,g=this.y-u;if(this.isCropped){var v=this._crop;v.flipX===this.flipX&&v.flipY===this.flipY||r.updateCropUVs(v,this.flipX,this.flipY),o=v.cw,h=v.ch,n=v.cx,a=v.cy}else o=r.cutWidth,h=r.cutHeight,n=r.cutX,a=r.cutY;var f=1,m=1;this.flipX&&(p+=l,f=-1),this.flipY&&(g+=d,m=-1);var y=r.source.resolution,b=o/y,x=h/y;s&&(p=Math.floor(p+.5),g=Math.floor(g+.5),b+=.5,x+=.5),t.translate(p,g),t.rotate(this.rotation),t.scale(this.scaleX*f,this.scaleY*m),t.drawImage(r.source.image,n,a,o,h,0,0,b,x),t.restore()}}};Object.assign(ht.prototype,dt);var ct=function(t,e){"string"==typeof e&&(e={frame:e});var i=t.poolManager?t.poolManager.allocate(K):null;return null===i?i=new ht(t):i.setParent(t).setActive(),i.modifyPorperties(e),t.addChild(i),i},ut={_drawImage:function(t,e,i,s,r,n){ct(this,{frame:e,x:i,y:s,width:r,height:n})},_drawTileSprite:function(t,e,i,s,r,n){var a=this.texture.get(e),o=a.width,h=a.height,l=r%o,d=n%h;0===l&&(l=o),0===d&&(d=h);for(var c=Math.ceil(r/o),u=Math.ceil(n/h),p=c-1,g=u-1,v=0;v>>16,o=(65280&r)>>>8,h=255&r;t.fillStyle="rgba("+a+","+o+","+h+","+n+")"},xt=function(t,e,i,s){var r=i||e.strokeColor,n=s||e.strokeAlpha,a=(16711680&r)>>>16,o=(65280&r)>>>8,h=255&r;t.strokeStyle="rgba("+a+","+o+","+h+","+n+")",t.lineWidth=e.lineWidth};const Ct=Phaser.Renderer.Canvas.SetTransform;var kt={renderWebGL:function(t,e,i,s){e.dirty&&(e.updateData(),e.dirty=!1),i.addToRenderList(e);var r=t.pipelines.set(e.pipeline),n=yt(e,i,s),a=r.calcMatrix.copyFrom(n.calc),o=e._displayOriginX,h=e._displayOriginY,l=i.alpha*e.alpha;t.pipelines.preBatch(e),e.isFilled&&vt(r,a,e,l,o,h),e.isStroked&&mt(r,e,l,o,h),t.pipelines.postBatch(e)},renderCanvas:function(t,e,i,s){e.dirty&&(e.updateData(),e.dirty=!1),i.addToRenderList(e);var r=t.currentContext;if(Ct(t,r,e,i,s)){var n=e._displayOriginX,a=e._displayOriginY,o=e.pathData,h=o.length-1,l=o[0]-n,d=o[1]-a;r.beginPath(),r.moveTo(l,d),e.closePath||(h-=2);for(var c=2;c0}get fillAlpha(){return this._fillAlpha}set fillAlpha(t){this._fillAlpha=t,this.isFilled=t>0&&null!=this._fillColor}setFillStyle(t,e){return void 0===e&&(e=1),this.fillColor=t,this.fillAlpha=e,this}get strokeColor(){return this._strokeColor}set strokeColor(t){this._strokeColor=t,this.isStroked=null!=t&&this._strokeAlpha>0&&this._lineWidth>0}get strokeAlpha(){return this._strokeAlpha}set strokeAlpha(t){this._strokeAlpha=t,this.isStroked=t>0&&null!=this._strokeColor&&this._lineWidth>0}get lineWidth(){return this._lineWidth}set lineWidth(t){this._lineWidth=t,this.isStroked=t>0&&null!=this._strokeColor}setStrokeStyle(t,e,i){return void 0===i&&(i=1),this.lineWidth=t,this.strokeColor=e,this.strokeAlpha=i,this}updateData(){return this}get width(){return this.geom.width}set width(t){this.resize(t,this.height)}get height(){return this.geom.height}set height(t){this.resize(this.width,t)}setSize(t,e){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}}Object.assign(St.prototype,kt);const Pt=Phaser.Utils.Objects.GetValue;let Tt=class{constructor(t,e,i,s,r){void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===s&&(s=0),void 0===r&&(r=0),this.cornerRadius={},this._width=0,this._height=0,this.setTo(t,e,i,s,r)}setTo(t,e,i,s,r){return this.setPosition(t,e),this.setRadius(r),this.setSize(i,s),this}setPosition(t,e){return this.x=t,this.y=e,this}setRadius(t){return void 0===t&&(t=0),this.radius=t,this}setSize(t,e){return this.width=t,this.height=e,this}get minWidth(){var t=this.cornerRadius;return Math.max(t.tl.x+t.tr.x,t.bl.x+t.br.x)}get minHeight(){var t=this.cornerRadius;return Math.max(t.tl.y+t.bl.y,t.tr.y+t.br.y)}get width(){return this._width}set width(t){null==t&&(t=0),this._width=Math.max(t,this.minWidth)}get height(){return this._height}set height(t){null==t&&(t=0),this._height=Math.max(t,this.minHeight)}get radius(){var t=this.cornerRadius;return Math.max(t.tl.x,t.tl.y,t.tr.x,t.tr.y,t.bl.x,t.bl.y,t.br.x,t.br.y)}set radius(t){var e,i;"number"==typeof t?(e=t,i=t):(e=Pt(t,"x",0),i=Pt(t,"y",0));var s=this.cornerRadius;s.tl=Ot(Pt(t,"tl",void 0),e,i),s.tr=Ot(Pt(t,"tr",void 0),e,i),s.bl=Ot(Pt(t,"bl",void 0),e,i),s.br=Ot(Pt(t,"br",void 0),e,i)}get radiusTL(){var t=this.cornerRadius.tl;return Math.max(t.x,t.y)}set radiusTL(t){Mt(this.cornerRadius.tl,t)}get radiusTR(){var t=this.cornerRadius.tr;return Math.max(t.x,t.y)}set radiusTR(t){Mt(this.cornerRadius.tr,t)}get radiusBL(){var t=this.cornerRadius.bl;return Math.max(t.x,t.y)}set radiusBL(t){Mt(this.cornerRadius.bl,t)}get radiusBR(){var t=this.cornerRadius.br;return Math.max(t.x,t.y)}set radiusBR(t){Mt(this.cornerRadius.br,t)}};var Ot=function(t,e,i){return void 0===t?t={x:e,y:i}:"number"==typeof t&&(t={x:t,y:t}),Et(t),t},Mt=function(t,e){"number"==typeof e?(t.x=e,t.y=e):(t.x=Pt(e,"x",0),t.y=Pt(e,"y",0)),Et(t)},Et=function(t){t.convex=t.x>=0||t.y>=0,t.x=Math.abs(t.x),t.y=Math.abs(t.y)},_t=function(t){return t.x>0&&t.y>0},Rt=function(t,e,i){var s=i.length;if(s>=2){var r=i[s-2],n=i[s-1];if(t===r&&e===n)return i}return i.push(t,e),i};const Lt=Phaser.Math.DegToRad;var Bt=function(t,e,i,s,r,n,a,o,h){a&&n>r?n-=360:!a&&n=p?1:s/p,f=r>=g?1:r/g,m=u.cornerRadius;t.save(),t.beginPath(),t.translate(e,i),o=m.tl,ee(o)?(h=o.x*v,l=o.y*f,te(o)?ie(t,h,l,h,l,180,270,!1,a):ie(t,0,0,h,l,90,0,!0,a),d=0,c=l):(t.lineTo(0,0),d=0,c=0),o=m.tr,ee(o)?(h=o.x*v,l=o.y*f,te(o)?ie(t,s-h,l,h,l,270,360,!1,a):ie(t,s,0,h,l,180,90,!0,a)):t.lineTo(s,0),o=m.br,ee(o)?(h=o.x*v,l=o.y*f,te(o)?ie(t,s-h,r-l,h,l,0,90,!1,a):ie(t,s,r,h,l,270,180,!0,a)):t.lineTo(s,r),o=m.bl,ee(o)?(h=o.x*v,l=o.y*f,te(o)?ie(t,h,r-l,h,l,90,180,!1,a):ie(t,0,r,h,l,360,270,!0,a)):t.lineTo(0,r),t.lineTo(d,c),t.closePath(),t.restore()},te=function(t){return!t.hasOwnProperty("convex")||t.convex},ee=function(t){return t.x>0&&t.y>0},ie=function(t,e,i,s,r,n,a,o,h){if(o&&a>n?a-=360:!o&&a0&&(e.strokeStyle=h,e.lineWidth=l,e.stroke())}(t.canvas,t.context,d,d,h,l,r,e,i,s,n,a,o)}},re=function(){se(this,this.fillStyle,this.strokeStyle,this.lineWidth,this.radius,this.fillColor2,this.isHorizontalGradient,this.iteration)};const ne=Phaser.Utils.Objects.GetValue;let ae=class extends $t{constructor(t,e,i,s,r,n,a,o,h,l,d,c){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=1),void 0===r&&(r=s),void 0===n&&(n=0),void 0===c&&(c=1),super(t,e,i,s,r,c),this.type="rexRoundRectangleCanvas";var u=ne(n,"radius",n),p=ne(n,"iteration",void 0);this.setRadius(u),this.setIteration(p),this.setFillStyle(a,l,d),this.setStrokeStyle(o,h)}get radius(){return this._radius}set radius(t){this.dirty|=this._radius!=t,this._radius=t}setRadius(t){return this.radius=t,this}get iteration(){return this._iteration}set iteration(t){this.dirty|=this._iteration!=t,this._iteration=t}setIteration(t){return this.iteration=t,this}get fillStyle(){return this._fillStyle}set fillStyle(t){t=qt(t,this.canvas,this.context),this.dirty|=this._fillStyle!=t,this._fillStyle=t}get fillColor2(){return this._fillColor2}set fillColor2(t){t=qt(t,this.canvas,this.context),this.dirty|=this._fillColor2!=t,this._fillColor2=t}get isHorizontalGradient(){return this._isHorizontalGradient}set isHorizontalGradient(t){this.dirty|=this._isHorizontalGradient!=t,this._isHorizontalGradient=t}setFillStyle(t,e,i){return void 0===i&&(i=!0),this.fillStyle=t,this.fillColor2=e,this.isHorizontalGradient=i,this}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){t=qt(t,this.canvas,this.context),this.dirty|=this._strokeStyle!=t,this._strokeStyle=t}get lineWidth(){return this._lineWidth}set lineWidth(t){this.dirty|=this._lineWidth!=t,this._lineWidth=t}setStrokeStyle(t,e){return this.strokeStyle=t,this.lineWidth=e,this}updateTexture(){return super.updateTexture((function(){this.clear(),re.call(this)}),this),this}};t.register("roundRectangleCanvas",(function(t,e,i,s,r,n,a,o,h,l){var d=new ae(this.scene,t,e,i,s,r,n,a,o,h,l);return this.scene.add.existing(d),d})),P(window,"RexPlugins.UI.RoundRectangleCanvas",ae);var oe=function(t,e){if(!t)return!1;if(t.hasOwnProperty(e))return!0;for(;t;){if(Object.getOwnPropertyDescriptor(t,e))return!0;t=t.__proto__}return!1},he=function(t,e,i){e&&!oe(t,`${e}X`)&&(Object.defineProperty(t,`${e}X`,{get:function(){return i.x},set:function(e){i.x=e,t.dirty=!0}}),Object.defineProperty(t,`${e}Y`,{get:function(){return i.y},set:function(e){i.y=e,t.dirty=!0}}),Object.defineProperty(t,`${e}T`,{get:function(){return i.t},set:function(e){i.t=e,t.dirty=!0}}))},le={setTLPosition(t,e){return this.geom.setTLPosition(t,e),this.dirty=!0,this},setTRPosition(t,e){return this.geom.setTRPosition(t,e),this.dirty=!0,this},setBLPosition(t,e){return this.geom.setBLPosition(t,e),this.dirty=!0,this},setBRPosition(t,e){return this.geom.setBRPosition(t,e),this.dirty=!0,this},resetCornerPosition(){return this.geom.resetCornerPosition(),this.dirty=!0,this},insertTopSidePoint(t,e,i,s){var r=this.geom.topSidePoints;if(Array.isArray(t))for(var n,a=0,o=(r=t).length;a=0;f--)y=g[f],b=ge(d,h,y.t)+y.x,x=ge(c,l,y.t)+y.y,Rt(b,x,e);for(Rt(d,c,e),me(v),f=v.length-1;f>=0;f--)y=v[f],b=ge(r,d,y.t)+y.x,x=ge(n,c,y.t)+y.y,Rt(b,x,e);return e.push(e[0],e[1]),this.pathIndexes=ve(e),this}get tlx(){return this.geom.tlx}set tlx(t){this.geom.tlx=t,this.dirty=!0}get tly(){return this.geom.tly}set tly(t){this.geom.tly=t,this.dirty=!0}get trx(){return this.geom.trx}set trx(t){this.geom.trx=t,this.dirty=!0}get try(){return this.geom.try}set try(t){this.geom.try=t,this.dirty=!0}get blx(){return this.geom.blx}set blx(t){this.geom.blx=t,this.dirty=!0}get bly(){return this.geom.bly}set bly(t){this.geom.bly=t,this.dirty=!0}get brx(){return this.geom.brx}set brx(t){this.geom.brx=t,this.dirty=!0}get bry(){return this.geom.bry}set bry(t){this.geom.bry=t,this.dirty=!0}get leftSidePoints(){return this.geom.leftSidePoints}get topSidePoints(){return this.geom.topSidePoints}get bottomSidePoints(){return this.geom.bottomSidePoints}get rightSidePoints(){return this.geom.rightSidePoints}}var me=function(t){t.length<=1||t.sort((function(t,e){return t.t-e.t}))};Object.assign(fe.prototype,le),t.register("QuadShape",(function(t,e,i,s,r,n){var a=new fe(this.scene,t,e,i,s,r,n);return this.scene.add.existing(a),a})),P(window,"RexPlugins.UI.QuadShape",fe);var ye=Phaser.Renderer.WebGL.Utils,be={renderWebGL:function(t,e,i,s){if(0!==e.width&&0!==e.height){i.addToRenderList(e);var r=e.frame,n=r.width,a=r.height,o=ye.getTintAppendFloatAlpha,h=t.pipelines.set(e.pipeline,e),l=h.setTexture2D(r.glTexture,e);t.pipelines.preBatch(e),h.batchTexture(e,r.glTexture,n,a,e.x,e.y,n/e.style.resolution,a/e.style.resolution,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,n,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,l),t.pipelines.postBatch(e)}},renderCanvas:function(t,e,i,s){0!==e.width&&0!==e.height&&(i.addToRenderList(e),t.batchSprite(e,e.frame,i,s))}};const xe=Phaser.Display.Canvas.CanvasPool;F();const Ce=Phaser.GameObjects.GameObject;class ke extends Ce{setStyle(t){return this.style.setStyle(t)}setFont(t){return this.style.setFont(t)}setFontFamily(t){return this.style.setFontFamily(t)}setFontSize(t){return this.style.setFontSize(t)}setFontStyle(t){return this.style.setFontStyle(t)}setTestString(t){return this.style.setTestString(t)}setFixedSize(t,e){return this.style.setFixedSize(t,e)}setBackgroundColor(t,e,i){return this.style.setBackgroundColor(t,e,i)}setBackgroundStrokeColor(t,e){return this.style.setBackgroundStrokeColor(t,e)}setBackgroundCornerRadius(t,e){return this.style.setBackgroundCornerRadius(t,e)}setFill(t){return this.style.setFill(t)}setColor(t){return this.style.setColor(t)}setStroke(t,e){return this.style.setStroke(t,e)}setShadow(t,e,i,s,r,n){return this.style.setShadow(t,e,i,s,r,n)}setShadowOffset(t,e){return this.style.setShadowOffset(t,e)}setShadowColor(t){return this.style.setShadowColor(t)}setShadowBlur(t){return this.style.setShadowBlur(t)}setShadowStroke(t){return this.style.setShadowStroke(t)}setShadowFill(t){return this.style.setShadowFill(t)}setUnderline(t,e,i){return this.style.setUnderline(t,e,i)}setUnderlineColor(t){return this.style.setUnderlineColor(t)}setUnderlineThickness(t){return this.style.setUnderlineThickness(t)}setUnderlineOffset(t){return this.style.setUnderlineOffset(t)}setStrikethrough(t,e,i){return this.style.setStrikethrough(t,e,i)}setStrikethroughColor(t){return this.style.setStrikethroughColor(t)}setStrikethroughThickness(t){return this.style.setStrikethroughThickness(t)}setStrikethroughOffset(t){return this.style.setStrikethroughOffset(t)}setWrapMode(t){return this.style.setWrapMode(t)}setWrapWidth(t){return this.style.setWrapWidth(t)}setWordWrapWidth(t){return this.style.setWrapWidth(t)}setAlign(t){return this.style.setHAlign(t)}setHAlign(t){return this.style.setHAlign(t)}setVAlign(t){return this.style.setVAlign(t)}get lineSpacing(){return this.style.lineSpacing}set lineSpacing(t){this.style.lineSpacing=t}setLineSpacing(t){return this.style.lineSpacing=t,this.updateText(!0),this}setXOffset(t){return this.style.setXOffset(t)}setMaxLines(t){return this.style.setMaxLines(t)}setResolution(t){return this.style.setResolution(t)}getTextMetrics(){return this.style.getTextMetrics()}setTextMetrics(t,e){return this.style.setTextMetrics(t,e)}measureTextMargins(t,e){return function(t,e,i){void 0===i&&(i={});var s=xe.create(this),r=s.getContext("2d",{willReadFrequently:!0});t.syncFont(s,r);var n=r.measureText(e),a=Math.ceil(n.width*t.baselineX),o=a,h=2*o;if(o=o*t.baselineY|0,s.width=a,s.height=h,r.fillStyle="#f00",r.fillRect(0,0,a,h),r.font=t._font,r.textBaseline="alphabetic",r.fillStyle="#000",r.fillText(t.testString,0,o),i.left=0,0===a||0===h||!r.getImageData(0,0,a,h))return xe.remove(s),i;for(var l=r.getImageData(0,0,a,h).data,d=!1,c=0;c * @copyright 2018 Photon Storm Ltd. diff --git a/plugins/gameobjects/blitter/blitterbase/bob/image/CanvasRender.js b/plugins/gameobjects/blitter/blitterbase/bob/image/CanvasRender.js index ef740db9cc..da72002766 100644 --- a/plugins/gameobjects/blitter/blitterbase/bob/image/CanvasRender.js +++ b/plugins/gameobjects/blitter/blitterbase/bob/image/CanvasRender.js @@ -1,4 +1,8 @@ var CanvasRender = function (ctx, dx, dy, roundPixels) { + var frame = this.frame; + if (!frame) { + return; + } ctx.save(); @@ -9,6 +13,28 @@ var CanvasRender = function (ctx, dx, dy, roundPixels) { var x = this.x - displayOriginX, y = this.y - displayOriginY; + var frameX, frameY; + var frameWidth, frameHeight; + if (this.isCropped) { + var crop = this._crop; + + if (crop.flipX !== this.flipX || crop.flipY !== this.flipY) { + frame.updateCropUVs(crop, this.flipX, this.flipY); + } + + frameWidth = crop.cw; + frameHeight = crop.ch; + + frameX = crop.cx; + frameY = crop.cy; + } else { + frameWidth = frame.cutWidth; + frameHeight = frame.cutHeight; + + frameX = frame.cutX; + frameY = frame.cutY; + } + var flipX = 1; var flipY = 1; @@ -21,9 +47,16 @@ var CanvasRender = function (ctx, dx, dy, roundPixels) { flipY = -1; } + var res = frame.source.resolution; + var fw = frameWidth / res; + var fh = frameHeight / res; + if (roundPixels) { - x = Math.round(x); - y = Math.round(y); + x = Math.floor(x + 0.5); + y = Math.floor(y + 0.5); + + fw += 0.5; + fh += 0.5; } ctx.translate(x, y); @@ -32,11 +65,10 @@ var CanvasRender = function (ctx, dx, dy, roundPixels) { ctx.scale(this.scaleX * flipX, this.scaleY * flipY); - var frame = this.frame; ctx.drawImage( frame.source.image, - frame.cutX, frame.cutY, width, height, - 0, 0, width, height, + frameX, frameY, frameWidth, frameHeight, + 0, 0, fw, fh, ); ctx.restore(); diff --git a/plugins/gameobjects/blitter/ninepatch/texture/DrawTileSprite.js b/plugins/gameobjects/blitter/ninepatch/texture/DrawTileSprite.js index b7e9161b73..eb1cf07331 100644 --- a/plugins/gameobjects/blitter/ninepatch/texture/DrawTileSprite.js +++ b/plugins/gameobjects/blitter/ninepatch/texture/DrawTileSprite.js @@ -2,16 +2,25 @@ import AddImage from '../../blitterbase/utils/AddImage.js'; var DrawTileSprite = function (key, frame, x, y, width, height) { var frameObj = this.texture.get(frame); + var frameWidth = frameObj.width, frameHeight = frameObj.height; - var cropLastWidth = width % frameWidth, - cropLastHeight = height % frameHeight; - var cropLastCol = (cropLastWidth !== 0), - cropLastRow = (cropLastHeight !== 0); + + var lastFrameWidth = width % frameWidth, + lastFrameHeight = height % frameHeight; + + if (lastFrameWidth === 0) { + lastFrameWidth = frameWidth; + } + if (lastFrameHeight === 0) { + lastFrameHeight = frameHeight; + } + var colCount = Math.ceil(width / frameWidth), rowCount = Math.ceil(height / frameHeight); var lastColCount = colCount - 1, lastRowCount = rowCount - 1; + for (var colIndex = 0; colIndex < colCount; colIndex++) { for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) { let bob = AddImage(this, { @@ -20,8 +29,8 @@ var DrawTileSprite = function (key, frame, x, y, width, height) { y: y + (rowIndex * frameHeight), }) - var cropWidth = (cropLastCol && (colIndex === lastColCount)) ? cropLastWidth : frameWidth; - var cropHeight = (cropLastRow && (rowIndex === lastRowCount)) ? cropLastHeight : frameHeight; + var cropWidth = (colIndex === lastColCount) ? lastFrameWidth : frameWidth; + var cropHeight = (rowIndex === lastRowCount) ? lastFrameHeight : frameHeight; if ((cropWidth !== frameWidth) || (cropHeight !== frameHeight)) { bob.setCrop(0, 0, cropWidth, cropHeight); }