You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1 line
18 KiB

  1. Array.prototype.shuffle||Object.defineProperty(Array.prototype,"shuffle",{enumerable:!1,writable:!1,value:function(){for(var a,b,c=this.length;c;a=Math.floor(Math.random()*c),b=this[--c],this[c]=this[a],this[a]=b);return this}}),Array.prototype.random||Object.defineProperty(Array.prototype,"random",{enumerable:!1,writable:!1,value:function(){return this[Math.floor(Math.random()*this.length)]}}),function(){let a="undefined"==typeof window?GLOBAL:window,b={};if("undefined"!=typeof module&&module.exports)"undefined"==typeof PIXI&&require("pixi.js"),module.exports=b;else if("undefined"==typeof PIXI)throw"pixi-particles requires pixi.js to be loaded first";a.PIXI.particles=a.PIXI.particles||b}(),function(a){let b=a.BLEND_MODES||a.blendModes,c=a.Texture,d={},e=d.DEG_TO_RADS=Math.PI/180;d.useAPI3=!1;let f=a.VERSION;f&&3<=parseInt(f.substring(0,f.indexOf(".")))&&(d.useAPI3=!0);let g=d.EMPTY_TEXTURE=null;if(d.useAPI3)g=d.EMPTY_TEXTURE=c.EMPTY,g.on=g.destroy=g.once=g.emit=function(){};else{let b=document.createElement("canvas");b.width=b.height=1,g=d.EMPTY_TEXTURE=a.Texture.fromCanvas(b),g.baseTexture.hasLoaded=!1,g.on=g.destroy=g.once=g.emit=function(){}}d.rotatePoint=function(a,b){if(!a)return;a*=e;let d=Math.sin(a),f=Math.cos(a),c=b.x*f-b.y*d,g=b.x*d+b.y*f;b.x=c,b.y=g},d.combineRGBComponents=function(a,c,d){return a<<16|c<<8|d},d.normalize=function(a){if(0!=a.x||0!=a.y){let b=1/d.length(a);a.x*=b,a.y*=b}},d.scaleBy=function(a,b){a.x*=b,a.y*=b},d.length=function(a){return Math.sqrt(a.x*a.x+a.y*a.y)},d.hexToRGB=function(a,b){b?b.length=0:b=[],"#"==a.charAt(0)?a=a.substr(1):0===a.indexOf("0x")&&(a=a.substr(2));let c;return 8==a.length&&(c=a.substr(0,2),a=a.substr(2)),b.push(parseInt(a.substr(0,2),16)),b.push(parseInt(a.substr(2,2),16)),b.push(parseInt(a.substr(4,2),16)),c&&b.push(parseInt(c,16)),b},d.generateEase=function(a){let b=a.length;return function(c){let d,e,f=0|b*c;return d=(c-f*(1/b))*b,e=a[f]||a[b-1],e.s+d*(2*(1-d)*(e.cp-e.s)+d*(e.e-e.s))}},d.getBlendMode=function(a){if(!a)return b.NORMAL;for(a=a.toUpperCase();0<=a.indexOf(" ");)a=a.replace(" ","_");return b[a]||b.NORMAL},a.particles.ParticleUtils=d}(PIXI),function(a){let c=a.particles.ParticleUtils,d=a.Sprite,e=c.useAPI3,f=function(b){e?d.call(this):d.call(this,c.EMPTY_TEXTURE),this.emitter=b,this.anchor.x=this.anchor.y=.5,this.velocity=new a.Point,this.direction=b.direction,this.maxLife=0,this.age=0,this.ease=null,this.extraData=null,this.startAlpha=0,this.endAlpha=0,this.startSpeed=0,this.endSpeed=0,this.acceleration=new a.Point,this.startScale=0,this.endScale=0,this.startColor=null,this._sR=0,this._sG=0,this._sB=0,this.endColor=null,this._eR=0,this._eG=0,this._eB=0,this._doAlpha=!1,this._doScale=!1,this._doSpeed=!1,this._doAcceleration=!1,this._doColor=!1,this._doNormalMovement=!1,this._oneOverLife=0,this.next=null,this.prev=null,this.init=this.init,this.Particle_init=this.Particle_init,this.update=this.update,this.Particle_update=this.Particle_update,this.applyArt=this.applyArt,this.kill=this.kill},g=f.prototype=Object.create(d.prototype);g.init=g.Particle_init=function(){this.age=0,this.velocity.x=this.startSpeed,this.velocity.y=0,c.rotatePoint(this.rotation,this.velocity),this.rotation*=c.DEG_TO_RADS,this.rotationSpeed*=c.DEG_TO_RADS,this.alpha=this.startAlpha,this.scale.x=this.scale.y=this.startScale,this.startColor&&(this._sR=this.startColor[0],this._sG=this.startColor[1],this._sB=this.startColor[2],this.endColor&&(this._eR=this.endColor[0],this._eG=this.endColor[1],this._eB=this.endColor[2])),this._doAlpha=this.startAlpha!=this.endAlpha,this._doSpeed=this.startSpeed!=this.endSpeed,this._doScale=this.startScale!=this.endScale,this._doColor=!!this.endColor,this._doAcceleration=0!==this.acceleration.x||0!==this.acceleration.y,this._doNormalMovement=this._doSpeed||0!==this.startSpeed||this._doAcceleration,this._oneOverLife=1/this.maxLife,this.tint=c.combineRGBComponents(this._sR,this._sG,this._sB),this.visible=!0,this.rawScale={x:this.scale.x,y:this.scale.y},this.rawPosition={x:this.position.x,y:this.position.y}},g.applyArt=function(a){e?this.texture=a||c.EMPTY_TEXTURE:this.setTexture(a||c.EMPTY_TEXTURE)},g.update=g.Particle_update=function(a){if(this.age+=a,this.age>=this.maxLife)return this.kill(),-1;let d=this.age*this._oneOverLife;if(this.ease&&(4==this.ease.length?d=this.ease(d,0,1,1):d=this.ease(d)),this._doAlpha&&(this.alpha=(this.endAlpha-this.startAlpha)*d+this.startAlpha),this._doScale){let a=(this.endScale-this.startScale)*d+this.startScale;this.rawScale.x=this.rawScale.y=a,this.scale.x=this.scale.y=2*~~(a/2)}if(this._doNormalMovement){if(this._doSpeed){let a=(this.endSpeed-this.startSpeed)*d+this.startSpeed;c.normalize(this.velocity),c.scaleBy(this.velocity,a)}else this._doAcceleration&&(this.velocity.x+=this.acceleration.x*a,this.velocity.y+=this.acceleration.y*a);let b=this.direction;if(b){let c=b.x,d=b.y,e=this.velocity.x,f=this.velocity.y;0<f&&0>d&&(f*=-1),this.rawPosition.x+=c*e*a,this.rawPosition.y+=d*f*a}else this.rawPosition.x+=this.velocity.x*a,this.rawPosition.y+=this.velocity.y*a;this.position.x=2*~~(this.rawPosition.x/2),this.position.y=2*~~(this.rawPosition.y/2)}if(this._doColor){let a=(this._eR-this._sR)*d+this._sR,e=(this._eG-this._sG)*d+this._sG,f=(this._eB-this._sB)*d+this._sB;this.tint=c.combineRGBComponents(a,e,f)}return 0===this.rotationSpeed?this.acceleration&&(this.allowRotation?this.rotation=Math.atan2(this.velocity.y,this.velocity.x):this.rotation=0):this.rotation+=this.rotationSpeed*a,d},g.kill=function(){this.emitter.recycle(this)},g.Sprite_Destroy=d.prototype.destroy,g.destroy=function(){this.parent&&this.parent.removeChild(this),this.Sprite_Destroy&&this.Sprite_Destroy(),this.emitter=this.velocity=this.startColor=this.endColor=this.ease=this.next=this.prev=null},f.parseArt=function(b){let c;for(c=b.length;0<=c;--c)"string"==typeof b[c]&&(b[c]=a.Texture.from(b[c]));for(c=b.length-1;0<c;--c)if(b[c].baseTexture!=b[c-1].baseTexture){window.console&&console.warn("PixiParticles: using particle textures from different images may hinder performance in WebGL");break}return b},f.parseData=function(a){return a},a.particles.Particle=f}(PIXI),function(a){let b=a.particles.ParticleUtils,c=a.particles.Particle,d=a.ParticleContainer,e=function(a,b,d){this.chance=d.chance||null,this.allowRotation=d.allowRotation||!1,this.randomColor=d.randomColor||!1,this.randomScale=d.randomScale||!1,this.randomSpeed=d.randomSpeed||!1,this.blendMode=d.blendMode,this._particleConstructor=c,this.particleImages=null,this.startAlpha=1,this.endAlpha=1,this.startSpeed=0,this.endSpeed=0,this.acceleration=null,this.startScale=1,this.endScale=1,this.minimumScaleMultiplier=1,this.startColor=null,this.endColor=null,this.minLifetime=0,this.maxLifetime=0,this.minStartRotation=0,this.maxStartRotation=0,this.minRotationSpeed=0,this.maxRotationSpeed=0,this.particleBlendMode=0,this.customEase=null,this.extraData=null,this._frequency=1,this.maxParticles=1e3,this.emitterLifetime=-1,this.spawnPos=null,this.spawnType=null,this._spawnFunc=null,this.spawnRect=null,this.spawnCircle=null,this.particlesPerWave=1,this.particleSpacing=0,this.angleStart=0,this.rotation=0,this.ownerPos=null,this._prevEmitterPos=null,this._prevPosIsValid=!1,this._posChanged=!1,this._parentIsPC=!1,this._parent=null,this.addAtBack=!1,this.particleCount=0,this._emit=!1,this._spawnTimer=0,this._emitterLife=-1,this._activeParticlesFirst=null,this._activeParticlesLast=null,this._poolFirst=null,this._origConfig=null,this._origArt=null,this.parent=a,b&&d&&this.init(b,d),this.recycle=this.recycle,this.update=this.update,this.rotate=this.rotate,this.updateSpawnPos=this.updateSpawnPos,this.updateOwnerPos=this.updateOwnerPos},f=e.prototype={},g=new a.Point;Object.defineProperty(f,"frequency",{get:function(){return this._frequency},set:function(a){this._frequency="number"==typeof a&&0<a?a:1}}),Object.defineProperty(f,"particleConstructor",{get:function(){return this._particleConstructor},set:function(a){if(a!=this._particleConstructor){this._particleConstructor=a,this.cleanup();for(let a=this._poolFirst;a;a=a.next)a.destroy();this._poolFirst=null,this._origConfig&&this._origArt&&this.init(this._origArt,this._origConfig)}}}),Object.defineProperty(f,"parent",{get:function(){return this._parent},set:function(a){if(this._parentIsPC)for(let a=this._poolFirst;a;a=a.next)a.parent&&a.parent.removeChild(a);this.cleanup(),this._parent=a,this._parentIsPC=d&&a&&a instanceof d}}),f.init=function(c,d){if(!c||!d)return;this.cleanup(),this._origConfig=d,this._origArt=c,c=Array.isArray(c)?c.slice():[c];let e=this._particleConstructor;this.particleImages=e.parseArt?e.parseArt(c):c,d.alpha?(this.startAlpha=d.alpha.start,this.endAlpha=d.alpha.end):this.startAlpha=this.endAlpha=1,d.speed?(this.startSpeed=d.speed.start,this.endSpeed=d.speed.end):this.startSpeed=this.endSpeed=0;let f=d.acceleration;f&&(f.x||f.y)?(this.endSpeed=this.startSpeed,this.acceleration=new a.Point(f.x,f.y)):this.acceleration=new a.Point,d.scale?(this.startScale=d.scale.start,this.endScale=d.scale.end,this.minimumScaleMultiplier=d.scale.minimumScaleMultiplier||1):this.startScale=this.endScale=this.minimumScaleMultiplier=1,d.color&&(this.startColor=this.randomColor?d.color.start.map(function(a){return b.hexToRGB(a)}):b.hexToRGB(d.color.start),this.endColor=d.color.start==d.color.end?null:this.randomColor?d.color.end.map(function(a){return b.hexToRGB(a)}):b.hexToRGB(d.color.end)),d.startRotation?(this.minStartRotation=d.startRotation.min,this.maxStartRotation=d.startRotation.max):this.minStartRotation=this.maxStartRotation=0,d.rotationSpeed?(this.minRotationSpeed=d.rotationSpeed.min,this.maxRotationSpeed=d.rotationSpeed.max):this.minRotationSpeed=this.maxRotationSpeed=0,this.minLifetime=d.lifetime.min,this.maxLifetime=d.lifetime.max,this.particleBlendMode=b.getBlendMode(d.blendMode),this.customEase=d.ease?"function"==typeof d.ease?d.ease:b.generateEase(d.ease):null,this.extraData=e.parseData?e.parseData(d.extraData):d.extraData||null,this.spawnRect=this.spawnCircle=null,this.particlesPerWave=1,this.particleSpacing=0,this.angleStart=0;let g;switch(d.spawnType){case"rect":this.spawnType="rect",this._spawnFunc=this._spawnRect;var h=d.spawnRect;this.spawnRect=new a.Rectangle(h.x,h.y,h.w,h.h);break;case"circle":this.spawnType="circle",this._spawnFunc=this._spawnCircle,g=d.spawnCircle,this.spawnCircle=new a.Circle(g.x,g.y,g.r);break;case"ring":this.spawnType="ring",this._spawnFunc=this._spawnRing,g=d.spawnCircle,this.spawnCircle=new a.Circle(g.x,g.y,g.r),this.spawnCircle.minRadius=g.minR;break;case"burst":this.spawnType="burst",this._spawnFunc=this._spawnBurst,this.particlesPerWave=d.particlesPerWave,this.particleSpacing=d.particleSpacing,this.angleStart=d.angleStart?d.angleStart:0;break;case"point":this.spawnType="point",this._spawnFunc=this._spawnPoint;break;default:this.spawnType="point",this._spawnFunc=this._spawnPoint;}this.direction=d.direction,this.frequency=d.frequency,this.emitterLifetime=d.emitterLifetime||-1,this.maxParticles=0<d.maxParticles?d.maxParticles:1e3,this.addAtBack=!!d.addAtBack,this.rotation=0,this.ownerPos=new a.Point,this.spawnPos=new a.Point(d.pos.x,d.pos.y),this._prevEmitterPos=this.spawnPos.clone(),this._prevPosIsValid=!1,this._spawnTimer=0,this.emit=!(d.emit!==void 0)||!!d.emit},f.recycle=function(a){a.next&&(a.next.prev=a.prev),a.prev&&(a.prev.next=a.next),a==this._activeParticlesLast&&(this._activeParticlesLast=a.prev),a==this._activeParticlesFirst&&(this._activeParticlesFirst=a.next),a.prev=null,a.next=this._poolFirst,this._poolFirst=a,this._parentIsPC?(a.alpha=0,a.visible=!1):a.parent&&a.parent.removeChild(a),--this.particleCount},f.rotate=function(a){if(this.rotation!=a){let c=a-this.rotation;this.rotation=a,b.rotatePoint(c,this.spawnPos),this._posChanged=!0}},f.updateSpawnPos=function(a,b){this._posChanged=!0,this.spawnPos.x=a,this.spawnPos.y=b},f.updateOwnerPos=function(a,b){this._posChanged=!0,this.ownerPos.x=a,this.ownerPos.y=b},f.resetPositionTracking=function(){this._prevPosIsValid=!1},Object.defineProperty(f,"emit",{get:function(){return this._emit},set:function(a){this._emit=!!a,this._emitterLife=this.emitterLifetime}}),f.update=function(a){let b=[];if(!this._parent)return;let c,d,e;for(d=this._activeParticlesFirst;d;d=e)e=d.next,d.update(a);let f,g;this._prevPosIsValid&&(f=this._prevEmitterPos.x,g=this._prevEmitterPos.y);let h=this.ownerPos.x+this.spawnPos.x,j=this.ownerPos.y+this.spawnPos.y;if(this.emit)for(this._spawnTimer-=a,this.chance&&(this._spawnTimer=1,Math.random()<this.chance&&(this._spawnTimer=0));0>=this._spawnTimer;){if(0<this._emitterLife&&(this._emitterLife-=this._frequency,0>=this._emitterLife)){this._spawnTimer=0,this._emitterLife=0,this.emit=!1;break}if(this.particleCount>=this.maxParticles){this._spawnTimer+=this._frequency;continue}var k;if(k=this.minLifetime==this.maxLifetime?this.minLifetime:Math.random()*(this.maxLifetime-this.minLifetime)+this.minLifetime,-this._spawnTimer<k){var l,m;if(this._prevPosIsValid&&this._posChanged){let b=1+this._spawnTimer/a;l=(h-f)*b+f,m=(j-g)*b+g}else l=h,m=j;c=0;for(let a=Math.min(this.particlesPerWave,this.maxParticles-this.particleCount);c<a;++c){var n;if(this._poolFirst?(n=this._poolFirst,this._poolFirst=this._poolFirst.next,n.next=null):n=new this.particleConstructor(this),b.push(n),1<this.particleImages.length?n.applyArt(this.particleImages.random()):n.applyArt(this.particleImages[0]),n.startAlpha=this.startAlpha,n.endAlpha=this.endAlpha,!this.randomSpeed)n.startSpeed=this.startSpeed,n.endSpeed=this.endSpeed;else{let a=this.startSpeed;n.startSpeed=a.min+~~(Math.random()*(a.max-a.min));let b=this.endSpeed;n.endSpeed=b.min+~~(Math.random()*(b.max-b.min))}if(n.acceleration.x=this.acceleration.x,n.acceleration.y=this.acceleration.y,1!=this.minimumScaleMultiplier){let a=Math.random()*(1-this.minimumScaleMultiplier)+this.minimumScaleMultiplier;n.startScale=this.startScale*a,n.endScale=this.endScale*a}else if(!this.randomScale)n.startScale=this.startScale,n.endScale=this.endScale;else{let a=this.startScale;n.startScale=a.min+~~(Math.random()*(a.max-a.min));let b=this.endScale;n.endScale=b.min+~~(Math.random()*(b.max-b.min))}if(!this.randomColor)n.startColor=this.startColor,n.endColor=this.endColor;else{let a=this.startColor;n.startColor=a[~~(Math.random()*a.length)];let b=this.endColor;n.endColor=b[~~(Math.random()*b.length)]}if(n.rotationSpeed=this.minRotationSpeed==this.maxRotationSpeed?this.minRotationSpeed:Math.random()*(this.maxRotationSpeed-this.minRotationSpeed)+this.minRotationSpeed,n.maxLife=k,n.blendMode=this.particleBlendMode,n.ease=this.customEase,n.extraData=this.extraData,this._spawnFunc(n,l,m,c),n.init(),this.allowRotation||(n.rotation=0),this.chance||n.update(-this._spawnTimer),!this._parentIsPC||!n.parent)this.addAtBack?this._parent.addChildAt(n,0):this._parent.addChild(n);else{let a=this._parent.children;if(a[0]==n)a.shift();else if(a[a.length-1]==n)a.pop();else{let b=a.indexOf(n);a.splice(b,1)}this.addAtBack?a.unshift(n):a.push(n)}this._activeParticlesLast?(this._activeParticlesLast.next=n,n.prev=this._activeParticlesLast,this._activeParticlesLast=n):this._activeParticlesLast=this._activeParticlesFirst=n,++this.particleCount}}this._spawnTimer+=this._frequency}return this._posChanged&&(this._prevEmitterPos.x=h,this._prevEmitterPos.y=j,this._prevPosIsValid=!0,this._posChanged=!1),b},f._spawnPoint=function(a,b,c){a.rotation=this.minStartRotation==this.maxStartRotation?this.minStartRotation+this.rotation:Math.random()*(this.maxStartRotation-this.minStartRotation)+this.minStartRotation+this.rotation,a.position.x=b,a.position.y=c},f._spawnRect=function(a,c,d){a.rotation=this.minStartRotation==this.maxStartRotation?this.minStartRotation+this.rotation:Math.random()*(this.maxStartRotation-this.minStartRotation)+this.minStartRotation+this.rotation,g.x=Math.random()*this.spawnRect.width+this.spawnRect.x,g.y=Math.random()*this.spawnRect.height+this.spawnRect.y,0!==this.rotation&&b.rotatePoint(this.rotation,g),a.position.x=c+g.x,a.position.y=d+g.y},f._spawnCircle=function(a,c,d){a.rotation=this.minStartRotation==this.maxStartRotation?this.minStartRotation+this.rotation:Math.random()*(this.maxStartRotation-this.minStartRotation)+this.minStartRotation+this.rotation,g.x=Math.random()*this.spawnCircle.radius,g.y=0,b.rotatePoint(360*Math.random(),g),g.x+=this.spawnCircle.x,g.y+=this.spawnCircle.y,0!==this.rotation&&b.rotatePoint(this.rotation,g),a.position.x=c+g.x,a.position.y=d+g.y},f._spawnRing=function(a,c,d){let e=this.spawnCircle;a.rotation=this.minStartRotation==this.maxStartRotation?this.minStartRotation+this.rotation:Math.random()*(this.maxStartRotation-this.minStartRotation)+this.minStartRotation+this.rotation,g.x=e.minRadius==e.radius?Math.random()*(e.radius-e.minRadius)+e.minRadius:e.radius,g.y=0;let f=360*Math.random();a.rotation+=f,b.rotatePoint(f,g),g.x+=this.spawnCircle.x,g.y+=this.spawnCircle.y,0!==this.rotation&&b.rotatePoint(this.rotation,g),a.position.x=c+g.x,a.position.y=d+g.y},f._spawnBurst=function(a,b,c,d){a.rotation=0===this.particleSpacing?360*Math.random():this.angleStart+this.particleSpacing*d+this.rotation,a.position.x=b,a.position.y=c},f.cleanup=function(){let a,b;for(a=this._activeParticlesFirst;a;a=b)b=a.next,this.recycle(a),a.parent&&a.parent.removeChild(a);this._activeParticlesFirst=this._activeParticlesLast=null,this.particleCount=0},f.destroy=function(){this.cleanup();let a;for(let b=this._poolFirst;b;b=a)a=b.next,b.destroy();this._poolFirst=this._parent=this.particleImages=this.spawnPos=this.ownerPos=this.startColor=this.endColor=this.customEase=null},a.particles.Emitter=e}(PIXI),function(){let a="undefined"==typeof window?GLOBAL:window;"undefined"==typeof cloudkid&&(a.cloudkid={}),Object.defineProperties(a.cloudkid,{AnimatedParticle:{get:function(){return console.warn("cloudkid namespace is deprecated, please use PIXI.particles"),PIXI.particles.AnimatedParticle}},Emitter:{get:function(){return console.warn("cloudkid namespace is deprecated, please use PIXI.particles"),PIXI.particles.Emitter}},Particle:{get:function(){return console.warn("cloudkid namespace is deprecated, please use PIXI.particles"),PIXI.particles.Particle}},ParticleUtils:{get:function(){return console.warn("cloudkid namespace is deprecated, please use PIXI.particles"),PIXI.particles.ParticleUtils}},PathParticle:{get:function(){return console.warn("cloudkid namespace is deprecated, please use PIXI.particles"),PIXI.particles.PathParticle}}})}();