@pixi/animate
Version:
PIXI plugin for the PixiAnimate Extension
12 lines (11 loc) • 26.2 kB
JavaScript
/*!
* @pixi/animate - v3.0.1
* Compiled Mon, 02 Oct 2023 14:40:30 UTC
*
* @pixi/animate is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*
* Copyright 2023, undefined, All Rights Reserved
*/this.PIXI=this.PIXI||{},this.PIXI.animate=function(g,et,it,rt,nt,L,at,M,S,ot,ht,lt,ct){"use strict";let I=null;g.utils=void 0,(e=>{function t(u){return u=u.substr(1),u.length===3&&(u=u.replace(/([a-f0-9])/g,"$1$1")),parseInt(u,16)}e.hexToUint=t;function s(u,m,p){const f=u.length;if(f<m+p&&(u.length=m+p,f<m))if(u.fill)u.fill(!1,f,m);else for(let _=f;_<m;++_)u[_]=!1;if(u.fill)u.fill(!0,m,m+p);else{const _=u.length;for(let d=m;d<_;++d)u[d]=!0}}e.fillFrames=s;const i={X:"x",Y:"y",A:"sx",B:"sy",C:"kx",D:"ky",R:"r",L:"a",T:"t",F:"c",V:"v"};function r(u,m){switch(u){case"c":{const p=m.split(",");return p.forEach((f,_,d)=>{d[_]=parseFloat(f)}),p}case"t":return m;case"v":return!!parseInt(m,10);default:return parseFloat(m)}}const n={D:"d",P:"p"},o=/(\-?\d*\.?\d*)([a-zA-Z]+)/;function a(u){const m={d:0,p:{}};let p=0,f="",_=!1,d;for(;p<=u.length;){const b=u[p];if(!_&&(n[d]||n[b]))d==="d"&&(m.d=r(d,f),d=null),b==="P"?(_=!0,++p):(d=n[b],++p),f="";else if(b==="E"){let F=u.indexOf(";",p);F<0&&(F=u.length);const y=u.substring(p+1,F);if(o.test(y)){const[,E,st]=o.exec(y);_?d&&(m.p[d]=r(d,f),m.p.e||(m.p.e={}),m.p.e[d]={s:parseFloat(E),n:st},d=null,f=""):m.e={s:parseFloat(E),n:st}}p=F+1}else i[b]?(d&&(m.p[d]=r(d,f)),d=i[b],f="",p++):b?(f+=b,p++):(d&&(m.p[d]=r(d,f)),f="",d=null,p++)}return m}function h(u){const m={};let p=0,f="",_=!1,d,b={};for(;p<=u.length;){const F=u[p];if(i[F])_||(_=!0,m[f]=b),d&&(b[d]=r(d,f)),d=i[F],f="",p++;else if(F==="W"){_||(_=!0,m[f]=b),d&&(b[d]=r(d,f),f="",d=null);let y=u.indexOf(" ",p);y<0&&(y=u.length),b.tw=a(u.substring(p+1,y)),p=y}else!F||F===" "?(p++,d&&(b[d]=r(d,f)),f="",d=null,b={},_=!1):(f+=F,p++)}return m}e.deserializeKeyframes=h;function l(u){const m=[],p=u.split(`
`),f=/^[a-z]{1,2}$/;for(let _=0;_<p.length;_++){const d=p[_].split(" ");for(let b=0;b<d.length;b++){const F=d[b];F[0]!=="#"&&!f.test(F)&&(d[b]=parseFloat(F))}m.push(d)}return m}e.deserializeShapes=l;function c(u){if(u.isMovieClip){const m=u;return m._timedChildTimelines.forEach(p=>{m.children.indexOf(p.target)===-1&&(I==null||I.add(p.target))}),!0}return!1}e.addMovieClips=c;function T(u,m,p){I||(I=u.plugins.prepare,I.registerFindHook(c)),I==null||I.upload(m).then(p)}e.upload=T})(g.utils||(g.utils={}));const G=2;function Y(e,t){const s=typeof t=="function"?t:t==null?void 0:t.complete,i=typeof t=="function"||t==null?void 0:t.progress;let r="",n=null,o,a=!1;const{version:h}=e;typeof h=="number"&&(Math.floor(h)!==Math.floor(G)?console.warn(`Asset version is not the major version expected of ${Math.floor(G)} - it may not load properly`,e):h>G&&console.warn("Asset has been published with a newer version than PixiAnimate expects. It may not load properly.",e)),t&&typeof t!="function"&&(r=t.basePath||"",n=t.parent,o=t.metadata,a=!!t.createInstance);function l(){const T=a&&typeof e.stage=="function"?new e.stage:null;n&&T&&n.addChild(T),s&&s(T)}const c=e.assets||{};if(c&&Object.keys(c).length){let T=0,u=0;const m=[];r&&(r+="/");for(const p in c){i&&T++;let f=null;o&&(o[p]?f=o[p]:o.default&&(f=o.default)),m.push(et.Assets.load({alias:[p],src:r+c[p],data:f}).then(_=>{if(i&&(u++,i(u/T)),!!_){if(_ instanceof rt.Spritesheet)e.spritesheets.push(_);else if(_ instanceof it.Texture)e.textures[p]=_;else if(Array.isArray(_)||typeof _=="string"){let d=_;typeof d=="string"&&(d=g.utils.deserializeShapes(d));for(let b=0;b<d.length;b++){const F=d[b];for(let y=0;y<F.length;y++){const E=F[y];typeof E=="string"&&E[0]==="#"&&(F[y]=g.utils.hexToUint(E))}}e.shapes[p]=d}}}))}Promise.all(m).then(l)}else l()}const $=new nt.EventEmitter;function O(e,t,s){return e+(t-e)*s}const k=Math.PI,w=k*2;function ut(e,t,s){return Math.abs(t-e)>k&&(t>e?e+=w:t+=w),e+(t-e)*s}function V(e,t,s){Math.abs(t-e)>k&&(t>e?e+=w:t+=w);const i=e+(t-e)*s;return i>k?i-w:i<-k?i+w:i}function dt(e,t,s){const i=e>>16&255,r=e>>8&255,n=e&255,o=t>>16&255,a=t>>8&255,h=t&255;let l=i+(o-i)*s;l<0?l=0:l>255&&(l=255);let c=r+(a-r)*s;c<0?c=0:c>255&&(c=255);let T=n+(h-n)*s;return T<0?T=0:T>255&&(T=255),l<<16|c<<8|T}const v=[];function pt(e,t,s){return v[0]=e[0]+(t[0]-e[0])*s,v[1]=e[1]+(t[1]-e[1])*s,v[2]=e[2]+(t[2]-e[2])*s,v[3]=e[3]+(t[3]-e[3])*s,v[4]=e[4]+(t[4]-e[4])*s,v[5]=e[5]+(t[5]-e[5])*s,v}const mt={x:O,y:O,sx:O,sy:O,kx:V,ky:V,r:ut,a:O,t:dt,v:null,c:pt,m:null,g:null};function z(e,t,s){switch(t){case"x":e.transform.position.x=s;break;case"y":e.transform.position.y=s;break;case"sx":e.transform.scale.x=s;break;case"sy":e.transform.scale.y=s;break;case"kx":e.transform.skew.x=s;break;case"ky":e.transform.skew.y=s;break;case"r":e.transform.rotation=s;break;case"a":e.alpha=s;break;case"t":e.i(s);break;case"c":e.setColorTransform(...s);break;case"v":e.visible=s;break;case"m":e.ma(s);break}}function R(e){return t=>Math.pow(t,e)}function D(e){return t=>1-Math.pow(1-t,e)}function j(e){return t=>(t*=2)<1?.5*Math.pow(t,e):1-.5*Math.abs(Math.pow(2-t,e))}const x=1,X=.3,B=.3*1.5,q={quadIn:R(2),quadOut:D(2),quadInOut:j(2),cubicIn:R(3),cubicOut:D(3),cubicInOut:j(3),quartIn:R(4),quartOut:D(4),quartInOut:j(4),quintIn:R(5),quintOut:D(5),quintInOut:j(5),sineIn:e=>1-Math.cos(e*k/2),sineOut:e=>Math.sin(e*k/2),sineInOut:e=>-.5*(Math.cos(k*e)-1),backIn:e=>e*e*((1.7+1)*e-1.7),backOut:e=>--e*e*((1.7+1)*e+1.7)+1,backInOut:e=>(e*=2)<1?.5*(e*e*((2.5925+1)*e-2.5925)):.5*((e-=2)*e*((2.5925+1)*e+2.5925)+2),circIn:e=>-(Math.sqrt(1-e*e)-1),circOut:e=>Math.sqrt(1- --e*e),circInOut:e=>(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),bounceIn:e=>1-q.bounceOut(1-e),bounceOut:e=>e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375,bounceInOut:e=>e<.5?q.bounceIn(e*2)*.5:q.bounceOut(e*2-1)*.5+.5,elasticIn:e=>{if(e===0||e===1)return e;const t=X/w*Math.asin(1/x);return-(x*Math.pow(2,10*(e-=1))*Math.sin((e-t)*w/X))},elasticOut:e=>{if(e===0||e===1)return e;const t=X/w*Math.asin(1/x);return x*Math.pow(2,-10*e)*Math.sin((e-t)*w/X)+1},elasticInOut:e=>{const t=B/w*Math.asin(1/x);return(e*=2)<1?-.5*(x*Math.pow(2,10*(e-=1))*Math.sin((e-t)*w/B)):x*Math.pow(2,-10*(e-=1))*Math.sin((e-t)*w/B)*.5+1}};function J(e){if(!e)return null;if(typeof e=="function")return e;if(e.n==="classic"){const t=e.s/100;return s=>(t+1)*s+-t*s*s}return q[e.n]}class A{constructor(t,s,i,r,n,o){var a;if(this.target=t,this.startProps=s,this.endProps={},this.duration=n,this.startFrame=r,this.endFrame=r+n,this.ease={},this.isTweenlessFrame=!i,i)for(const h in i)h!=="e"&&(this.endProps[h]=i[h],(a=i.e)!=null&&a[h]?this.ease[h]=J(i.e[h]):this.ease[h]=o);for(const h in s)this.endProps.hasOwnProperty(h)||(this.endProps[h]=s[h])}setPosition(t){if(t>=this.endFrame){this.setToEnd();return}if(this.isTweenlessFrame){this.setToEnd();return}const s=(t-this.startFrame)/this.duration,i=this.target,r=this.startProps,n=this.endProps;for(const o in n){const a=o,h=mt[a];let l=s;this.ease[o]&&(l=this.ease[o](s)),h?z(i,a,h(r[a],n[a],l)):z(i,a,r[a])}}setToEnd(){const t=this.endProps,s=this.target;for(const i in t)z(s,i,t[i])}}class U extends Array{constructor(){super()}static create(t){const s=Object.create(U.prototype);return s.target=t,s._currentProps={},s}addTween(t,s,i,r){this.extendLastFrame(s-1);const n=Object.assign({},this._currentProps);for(const a in t){const h=a;if(!Object.hasOwnProperty.call(this._currentProps,a)){const l=n[h]=this.getPropFromShorthand(h);for(let c=this.length-1;c>=0;--c)this[c].startProps[h]=l,this[c].endProps[h]=l}}const o=new A(this.target,n,t,s,i,r);s===this[this.length-1].startFrame?this[this.length-1]=o:this.push(o),Object.assign(this._currentProps,o.endProps)}addKeyframe(t,s,i=0){if(this.length&&this[this.length-1].startFrame>=s){for(let r=this.length-1;r>=0;--r){const n=this[r];if(n.startFrame===s){Object.assign(n.startProps,t),n.endProps=Object.assign({},n.startProps,n.endProps);for(let o=r+1;o<this.length;++o){const a=this[o];a.startProps=Object.assign({},t,a.startProps),a.endProps=Object.assign({},a.startProps,a.endProps)}break}else if(n.startFrame<s&&n.endFrame>s&&n.isTweenlessFrame){n.endFrame=s-1;const o=Object.assign({},n.endProps,t),a=new A(this.target,o,null,s,i);this.splice(r,0,a);for(let h=r+1;h<this.length;++h){const l=this[h];l.startProps=Object.assign({},t,l.startProps),l.endProps=Object.assign({},l.startProps,l.endProps)}break}else if(n.endFrame<s){const o=Object.assign({},n.endProps,t),a=new A(this.target,o,null,s,i);this.splice(r,0,a);for(let h=r+1;h<this.length;++h){const l=this[h];l.startProps=Object.assign({},t,l.startProps),l.endProps=Object.assign({},l.startProps,l.endProps)}break}}Object.assign(this._currentProps,t,this._currentProps)}else{this.extendLastFrame(s-1);const r=Object.assign({},this._currentProps,t),n=new A(this.target,r,null,s,i);this.push(n),Object.assign(this._currentProps,n.endProps)}}extendLastFrame(t){if(this.length){const s=this[this.length-1];s.endFrame<t&&(s.isTweenlessFrame?(s.endFrame=t,s.duration=t-s.startFrame):this.addKeyframe(this._currentProps,s.endFrame+1,t-(s.endFrame+1)))}}getPropFromShorthand(t){const s=this.target;switch(t){case"x":return s.position.x;case"y":return s.position.y;case"sx":return s.scale.x;case"sy":return s.scale.y;case"kx":return s.skew.x;case"ky":return s.skew.y;case"r":return s.rotation;case"a":return s.alpha;case"v":return s.visible;case"m":return s.mask}return null}destroy(){this._currentProps=null,this.length=0}}class Z extends at.Container{constructor(){super(...arguments),this.ac=super.addChild,this.re=this.setRenderable,this.t=super.setTransform,this.ma=this.setMask,this.a=this.setAlpha,this.i=this.setTint,this.c=this.setColorTransform}setRenderable(t){return this.renderable=!!t,this}setMask(t){return t&&!(t instanceof M.Graphics)&&!(t instanceof S.Sprite)?(typeof console!="undefined"&&console.warn&&console.warn("Warning: Masks can only be PIXI.Graphics or PIXI.Sprite objects."),this):(this.mask=t,this)}setAlpha(t){return this.alpha=t,this}setTint(t){typeof t=="string"&&(t=g.utils.hexToUint(t));const s=t>>16&255,i=t>>8&255,r=t&255;return this.setColorTransform(s/255,0,i/255,0,r/255,0)}setColorTransform(t,s,i,r,n,o){const a=this.colorTransformFilter;return a.matrix[0]=t,a.matrix[4]=s,a.matrix[6]=i,a.matrix[9]=r,a.matrix[12]=n,a.matrix[14]=o,this.filters=[a],this}set colorTransformFilter(t){this._colorTransformFilter=t}get colorTransformFilter(){return this._colorTransformFilter||new L.ColorMatrixFilter}}const W=ot.Ticker.shared,P=class extends Z{constructor(t,s,i,r,n){if(super(),this.isMovieClip=!0,this.am=this.addTimedMask,this.tw=this.addTween,this.at=this.addTimedChild,this.aa=this.addAction,this.ps=this.playSound,t=t===void 0?{}:t,typeof t=="number"?t={mode:t||P.INDEPENDENT,duration:s||0,loop:i===void 0?!0:i,labels:n||{},framerate:r||0,startPosition:0}:t=Object.assign({mode:P.INDEPENDENT,startPosition:0,loop:!0,labels:{},duration:0,framerate:0},t),this.mode=t.mode,this.startPosition=t.startPosition,this.loop=!!t.loop,this.currentFrame=0,this._labels=[],this._labelDict=t.labels,t.labels){for(const o in t.labels){const a={label:o,position:t.labels[o]};this._labels.push(a)}this._labels.sort((o,a)=>o.position-a.position)}this.selfAdvance=!0,this.paused=!1,this.actionsEnabled=!0,this.autoReset=!0,this._synchOffset=0,this._prevPos=-1,this._t=0,this._framerate=t.framerate,this._duration=0,this._totalFrames=t.duration,this._timelines=[],this._timedChildTimelines=[],this._depthSorted=[],this._actions=[],this._beforeUpdate=null,this.parentStartPosition=0,this.mode===P.INDEPENDENT&&(this._tickListener=this._tickListener.bind(this),this._onAdded=this._onAdded.bind(this),this._onRemoved=this._onRemoved.bind(this),this.on("added",this._onAdded),this.on("removed",this._onRemoved)),t.framerate&&(this.framerate=t.framerate),this.advance=this.advance,this._updateTimeline=this._updateTimeline,this._setTimelinePosition=this._setTimelinePosition,this._goto=this._goto}_onAdded(){this._framerate||(this.framerate=this.parentFramerate),W.add(this._tickListener,null)}_tickListener(t){if(this.paused||!this.selfAdvance){this._prevPos<0&&this._goto(this.currentFrame);return}const s=t/ht.settings.TARGET_FPMS/1e3;this.advance(s)}_onRemoved(){W.remove(this._tickListener,null)}get labels(){return this._labels}get labelsMap(){return this._labelDict}get currentLabel(){const t=this._labels;let s=null;for(let i=0,r=t.length;i<r&&t[i].position<=this.currentFrame;++i)s=t[i].label;return s}get elapsedTime(){return this._t}set elapsedTime(t){this._t=t}get framerate(){return this._framerate}set framerate(t){t>0?(this._framerate?this._t*=this._framerate/t:this._t=this.currentFrame/t,this._framerate=t,this._duration=t?this._totalFrames/t:0):this._t=this._framerate=this._duration=0}get totalFrames(){return this._totalFrames}_autoExtend(t){this._totalFrames<t&&(this._totalFrames=t)}_parseProperties(t){typeof t.t=="string"?t.t=g.utils.hexToUint(t.t):typeof t.v=="number"&&(t.v=!!t.v)}_getChildTimeline(t){for(let i=this._timelines.length-1;i>=0;--i)if(this._timelines[i].target===t)return this._timelines[i];const s=U.create(t);return this._timelines.push(s),s}addTimedMask(t,s){for(const i in s)this.addKeyframe(t,{m:s[i]},parseInt(i,10));return this._setTimelinePosition(this.currentFrame,this.currentFrame,!0),this}addTween(t,s,i,r,n){const o=this._getChildTimeline(t);return this._parseProperties(s),o.addTween(s,i,r,n),this._autoExtend(i+r),this}addKeyframe(t,s,i){const r=this._getChildTimeline(t),{tw:n}=s;return delete s.tw,this._parseProperties(s),r.addKeyframe(s,i),this._autoExtend(i),n&&this.addTween(t,n.p,i,n.d,J(n.e)),this}addTimedChild(t,s,i,r){var n,o;s===void 0&&(s=0),(i===void 0||i<1)&&(i=this._totalFrames||1),t instanceof P&&t.mode===P.SYNCHED&&(t.parentStartPosition=s);let a;for(let h=this._timedChildTimelines.length-1;h>=0;--h)if(this._timedChildTimelines[h].target===t){a=this._timedChildTimelines[h];break}if(a||(a=[],a.target=t,this._timedChildTimelines.push(a)),g.utils.fillFrames(a,s,i),this._totalFrames<s+i&&(this._totalFrames=s+i),r){typeof r=="string"&&(r=g.utils.deserializeKeyframes(r));let h=!1;for(const l in r)if(r[l].kx||r[l].ky){h=!0;break}if(h)for(const l in r)r[l].r!==void 0&&(r[l].kx=r[l].kx||r[l].r*-1,r[l].ky=r[l].ky||r[l].r,delete r[l].r),((o=(n=r[l].tw)==null?void 0:n.p)==null?void 0:o.r)!==void 0&&(r[l].tw.p.kx=r[l].tw.p.kx||r[l].tw.p.r*-1,r[l].tw.p.ky=r[l].tw.p.ky||r[l].tw.p.r,delete r[l].tw.p.r);for(const l in r)this.addKeyframe(t,r[l],parseInt(l,10));this._getChildTimeline(t).extendLastFrame(s+i-1)}return this._setTimelinePosition(s,this.currentFrame,!0),this}addAction(t,s){if(typeof s=="string"){const r=this._labelDict[s];if(r===void 0)throw new Error(`The label '${s}' does not exist on this timeline`);s=r}const i=this._actions;return i.length<=s&&(i.length=s+1),this._totalFrames<s&&(this._totalFrames=s),i[s]?i[s].push(t):i[s]=[t],this}playSound(t,s){return $.emit("play",t,!!s,this),this}play(){this.paused=!1}stop(){this.paused=!0}gotoAndPlay(t){this.paused=!1,this._goto(t)}gotoAndStop(t){this.paused=!0,this._goto(t)}get parentFramerate(){let t=this,s=t._framerate;for(;(t=t.parent)&&!s;)t.mode===P.INDEPENDENT&&(s=t._framerate);return s||P.DEFAULT_FRAMERATE}advance(t){this._framerate||(this.framerate=this.parentFramerate),t&&(this._t+=t),this._t>this._duration&&(this._t=this.loop?this._t%this._duration:this._duration),this.currentFrame=Math.floor(this._t*this._framerate+1e-8),this.currentFrame>=this._totalFrames&&(this.currentFrame=this._totalFrames-1);let s;this._beforeUpdate&&(s=this._beforeUpdate(this)),this._updateTimeline(),s&&s()}_goto(t){const s=typeof t=="string"?this._labelDict[t]:t;s!==void 0&&(this._prevPos=NaN,this.currentFrame=s,this._framerate||(this.framerate=this.parentFramerate),this._framerate>0?this._t=s/this._framerate:this._t=0,this._updateTimeline())}_reset(){this._prevPos=-1,this._t=0,this.currentFrame=0}_updateTimeline(){const t=this.mode!==P.INDEPENDENT;t&&(this.currentFrame=this.startPosition+(this.mode===P.SINGLE_FRAME?0:this._synchOffset),this.currentFrame>=this._totalFrames&&(this.currentFrame%=this._totalFrames)),this._prevPos!==this.currentFrame&&(this._setTimelinePosition(this._prevPos,this.currentFrame,t?!1:this.actionsEnabled),this._prevPos=this.currentFrame)}_setTimelinePosition(t,s,i){if(t!==s&&i){let h;isNaN(t)?h=s:h=t>=this._totalFrames-1?0:t+1;const l=[];if(s<h){for(let c=h;c<this._actions.length;++c)this._actions[c]&&l.push(c);for(let c=0;c<=s;++c)this._actions[c]&&l.push(c)}else for(let c=h;c<=s;++c)this._actions[c]&&l.push(c);if(l.length){const c=this.currentFrame;for(let T=0;T<l.length;++T){const u=l[T];if(this._setTimelinePosition(u,u,!0),this.currentFrame!==c||u===s)return;if(this.paused){this.currentFrame=u;return}}}}const r=this._timelines;for(let h=r.length-1;h>=0;--h){const l=r[h];for(let c=0,T=l.length;c<T;++c){const u=l[c];if(s>=u.startFrame&&s<=u.endFrame){u.setPosition(s);break}}}const n=this._timedChildTimelines,o=this._depthSorted;for(let h=0,l=n.length;h<l;++h){const c=n[h].target,T=n[h][s];T?(o.push(c),c.parent!==this&&(this.addChild(c),c instanceof P&&c.mode===P.INDEPENDENT&&c.autoReset&&c._reset())):!T&&c.parent===this&&this.removeChild(c)}for(let h=0,l=o.length;h<l;h++){const c=o[h];this.children.indexOf(c)!==h&&this.addChildAt(c,h)}o.length=0;const a=this.children;for(let h=0,l=a.length;h<l;++h){const c=a[h];c instanceof P&&c.mode===P.SYNCHED&&(c._synchOffset=s-c.parentStartPosition,c._updateTimeline())}if(i&&this._actions&&this._actions[s]){const h=this._actions[s];for(let l=0;l<h.length;++l)h[l].call(this)}}destroy(t){this._tickListener&&(W.remove(this._tickListener,null),this._tickListener=null);const s=[],i=this._timelines;if(i)for(let n=0;n<i.length;n++){const o=i[n];s.push(o.target),o.destroy()}const r=this._timedChildTimelines;if(r)for(let n=0;n<r.length;n++){const o=r[n];s.indexOf(o.target)<0&&s.push(o.target),o.length=0}for(let n=0;n<s.length;n++)this.children.indexOf(s[n])<0&&s[n].destroy(t);s.length=0,this._actions=null,this._timelines=null,this._depthSorted=null,this._timedChildTimelines=null,this._beforeUpdate=null,this._labels=null,this._labelDict=null,super.destroy(t)}};let C=P;C.INDEPENDENT=0,C.SINGLE_FRAME=1,C.SYNCHED=2,C.DEFAULT_FRAMERATE=24;class ft extends lt.Application{constructor(){super(...arguments),this.sound=$,this.instance=null}load(t,s,i){return Y(t,{parent:this.stage,createInstance:!0,complete:r=>{this.instance=r,s&&s(this.instance)},basePath:i})}destroy(t,s){this.instance&&(this.instance.destroy(!0),this.instance=null),super.destroy(t,s)}}const _t=[];class N{constructor(){this._update=this.update.bind(this),this.init(null,0,0,!1,null)}init(t,s,i,r,n){this.instance=t,this.loop=r,this.start=s,this.end=i,this.callback=n,t&&(t.loop=!1,t.gotoAndStop(s),t._beforeUpdate=this._update)}destroy(){this.instance._beforeUpdate=null,this.init(null,0,0,!1,null),N._pool.push(this)}update(t){let s;return t.currentFrame>=this.end&&(t.currentFrame=this.end,this.loop?(t._updateTimeline(),t.gotoAndPlay(this.start)):(t.stop(),this.callback&&(s=this.callback),this.stop())),s}stop(){Q._internalStop(this)}get progress(){const t=(this.instance.currentFrame-this.start)/(this.end-this.start);return Math.max(0,Math.min(1,t))}static get _pool(){return _t}static create(t,s,i,r,n){let o;return this._pool.length?o=this._pool.pop():o=new N,o.init(t,s,i,r,n),o}}const gt=[];class Q{static get _timelines(){return gt}static get STOP_LABEL(){return"_stop"}static get LOOP_LABEL(){return"_loop"}static play(t,s,i){let r=!1,n,o;if(!s||typeof s=="function")n=0,o=t.totalFrames-1,s&&typeof s=="function"&&(i=s,s=null);else{if(n=t.labelsMap[s],o=t.labelsMap[s+this.STOP_LABEL],o===void 0&&(o=t.labelsMap[s+this.LOOP_LABEL],r=!0),n===void 0)throw new Error(`No start label matching "${s}"`);if(o===void 0)throw new Error(`No end label matching "${s}"`)}return this.fromTo(t,n,o,r,i)}static to(t,s,i){return this.fromTo(t,t.currentFrame,s,!1,i)}static fromTo(t,s,i,r,n){if(typeof s=="string"){const a=s;if(s=t.labelsMap[a],s===void 0)throw new Error(`No start label matching "${a}"`)}if(typeof i=="string"){const a=i;if(i=t.labelsMap[a],i===void 0)throw new Error(`No end label matching "${a}"`)}if(s<0)throw new Error("Start frame is out of bounds");if(i>=t.totalFrames)throw new Error("End frame is out of bounds");if(s>=i)throw new Error("End frame is before start frame");this.stop(t),r=!!r;const o=N.create(t,s,i,r,n);return this._timelines.push(o),t.currentFrame!==s?t.gotoAndPlay(s):t.play(),o}static stop(t){for(let s=0,i=this._timelines.length;s<i;s++){const r=this._timelines[s];if(r.instance===t){this._internalStop(r);break}}}static stopAll(){for(let t=this._timelines.length-1;t>=0;t--)this._internalStop(this._timelines[t])}static _internalStop(t){this._timelines.splice(this._timelines.indexOf(t),1),t.instance.stop(),t.destroy()}}class bt extends S.Sprite{constructor(){super(...arguments),this.re=this.setRenderable,this.t=super.setTransform,this.ma=this.setMask,this.a=this.setAlpha,this.i=this.setTint,this.c=this.setColorTransform}setRenderable(t){return this.renderable=!!t,this}setMask(t){return t&&!(t instanceof M.Graphics)&&!(t instanceof S.Sprite)?(typeof console!="undefined"&&console.warn&&console.warn("Warning: Masks can only be PIXI.Graphics or PIXI.Sprite objects."),this):(this.mask=t,this)}setAlpha(t){return this.alpha=t,this}setTint(t){return typeof t=="string"&&(t=g.utils.hexToUint(t)),this.tint=t,this}setColorTransform(t,s,i,r,n,o){const a=this.colorTransformFilter;return a.matrix[0]=t,a.matrix[4]=s,a.matrix[6]=i,a.matrix[9]=r,a.matrix[12]=n,a.matrix[14]=o,this.filters=[a],this}set colorTransformFilter(t){this._colorTransformFilter=t}get colorTransformFilter(){return this._colorTransformFilter||new L.ColorMatrixFilter}}class Tt extends M.Graphics{constructor(t){super(t),this.d=this.drawCommands,this.cp=super.closePath,this.bh=super.beginHole,this.eh=super.endHole,this.m=super.moveTo,this.l=super.lineTo,this.q=super.quadraticCurveTo,this.b=super.bezierCurveTo,this.f=super.beginFill,this.dr=super.drawRect,this.rr=super.drawRoundedRect,this.rc=super.drawRoundedRect,this.dc=super.drawCircle,this.ar=super.arc,this.at=super.arcTo,this.de=super.drawEllipse,this.re=this.setRenderable,this.t=super.setTransform,this.ma=this.setMask,this.a=this.setAlpha,this.i=this.setTint,this.s=super.lineStyle}drawCommands(t){let s;const i=[];let r=0;for(;r<=t.length;){const n=t[r++];n===void 0||this[n]?(s&&(this[s].apply(this,i),i.length=0),s=n):i.push(n)}return this}s(...t){return super.lineStyle(...t)}lf(t){return console.warn("Linear gradient fills are not supported"),this.f(t[0])}rf(t){return console.warn("Radial gradient fills are not supported"),this.f(t[0])}bf(){return console.warn("Bitmap fills are not supported"),this.f(0)}sd(){return console.warn("Dashed strokes are not supported"),this}bs(){return console.warn("Bitmap strokes are not supported"),this}ls(){return console.warn("Linear gradient strokes are not supported"),this}rs(){return console.warn("Radial gradient strokes are not supported"),this}setRenderable(t){return this.renderable=!!t,this}setMask(t){return t&&!(t instanceof M.Graphics)&&!(t instanceof S.Sprite)?(typeof console!="undefined"&&console.warn&&console.warn("Warning: Masks can only be PIXI.Graphics or PIXI.Sprite objects."),this):(this.mask=t,this)}setAlpha(t){return this.alpha=t,this}setTint(t){typeof t=="string"&&(t=g.utils.hexToUint(t));const s=t>>16&255,i=t>>8&255,r=t&255;return this.setColorTransform(s/255,0,i/255,0,r/255,0)}setColorTransform(t,s,i,r,n,o){const a=this.colorTransformFilter;return a.matrix[0]=t,a.matrix[4]=s,a.matrix[6]=i,a.matrix[9]=r,a.matrix[12]=n,a.matrix[14]=o,this.filters=[a],this}c(t,s,i,r,n,o){return this.setColorTransform(t,s,i,r,n,o)}set colorTransformFilter(t){this._colorTransformFilter=t}get colorTransformFilter(){return this._colorTransformFilter||new L.ColorMatrixFilter}}var K=(e=>(e[e.center=0]="center",e[e.right=1]="right",e[e.left=-1]="left",e))(K||{});const tt={o:"font",z:"fontSize",f:"fontFamily",y:"fontStyle",g:"fontWeight",i:"fill",a:"align",s:"stroke",t:"strokeThickness",w:"wordWrap",d:"wordWrapWidth",l:"lineHeight",h:"dropShadow",c:"dropShadowColor",n:"dropShadowAngle",b:"dropShadowBlur",p:"padding",x:"textBaseline",j:"lineJoin",m:"miterLimit",e:"letterSpacing"};function H(e,t){return e===void 0?t:e}class Ft extends ct.Text{constructor(){super(...arguments),this.g=this.setAlign,this.ss=this.setStyle,this.sh=this.setShadow,this.re=this.setRenderable,this.t=super.setTransform,this.ma=this.setMask,this.a=this.setAlpha,this.i=this.setTint,this.c=this.setColorTransform}setAlign(t){return typeof t=="string"&&(t=K[t]),this.style.align=K[t]||"left",this.anchor.x=(t+1)/2,this}setStyle(t){for(const s in tt)t[s]!==void 0&&(t[tt[s]]=t[s],delete t[s]);return this.style=t,this}setShadow(t,s,i){const r=this.style;return r.dropShadow=!0,t&&typeof t=="number"&&(t=`#${t.toString(16)}`),r.dropShadowColor=H(t,r.dropShadowColor),r.dropShadowAngle=H(s,r.dropShadowAngle),r.dropShadowDistance=H(i,r.dropShadowDistance),this}setRenderable(t){return this.renderable=!!t,this}setMask(t){return t&&!(t instanceof M.Graphics)&&!(t instanceof S.Sprite)?(typeof console!="undefined"&&console.warn&&console.warn("Warning: Masks can only be PIXI.Graphics or PIXI.Sprite objects."),this):(this.mask=t,this)}setAlpha(t){return this.alpha=t,this}setTint(t){typeof t=="string"&&(t=g.utils.hexToUint(t));const s=t>>16&255,i=t>>8&255,r=t&255;return this.setColorTransform(s/255,0,i/255,0,r/255,0)}setColorTransform(t,s,i,r,n,o){const a=this.colorTransformFilter;return a.matrix[0]=t,a.matrix[4]=s,a.matrix[6]=i,a.matrix[9]=r,a.matrix[12]=n,a.matrix[14]=o,this.filters=[a],this}set colorTransformFilter(t){this._colorTransformFilter=t}get colorTransformFilter(){return this._colorTransformFilter||new L.ColorMatrixFilter}}const Pt="3.0.1";return g.Animator=Q,g.AnimatorTimeline=N,g.Container=Z,g.Graphics=Tt,g.MovieClip=C,g.Scene=ft,g.Sprite=bt,g.Text=Ft,g.Timeline=U,g.Tween=A,g.VERSION=Pt,g.load=Y,g.sound=$,g}({},PIXI,PIXI,PIXI,PIXI.utils,PIXI.filters,PIXI,PIXI,PIXI,PIXI,PIXI,PIXI,PIXI);
//# sourceMappingURL=pixi-animate.js.map