Path: blob/main/projects/particle-clicker/js/event.js
1834 views
function ParticleEvent(t,a,i){switch(this.work=void 0!==i&&i,this.type=t,this.length=0,this.radius=0,this.direction=0,this.sign=Math.random()-.5>=0?1:-1,this.alpha=this.work?.5:1,this.count=a,this.type.name){case"electron":this.length=detector.radius.siliconSpace*detector.ratio+Math.round((detector.radius.ecal*detector.ratio+10-detector.radius.siliconSpace*detector.ratio)*Math.random()),this.direction=Math.random()*Math.PI*2,this.radius=20+Math.round(80*Math.random());break;case"jet":this.length=detector.radius.ecal*detector.ratio+Math.round((detector.radius.mucal*detector.ratio-detector.radius.ecal*detector.ratio)*Math.random()),this.direction=Math.random()*Math.PI*2,this.radius=40+Math.round(160*Math.random());break;case"muon":this.length=detector.radius.mucal*detector.ratio+3*detector.radius.mucalDark*detector.ratio+Math.round((4*detector.radius.mucalLight*detector.ratio+2*detector.radius.mucalDark*detector.ratio)*Math.random()),this.direction=Math.random()*Math.PI*2,this.radius=200+Math.round(400*Math.random())}this.draw(16,!0)}ParticleEvent.prototype.draw=function(t,a){a=void 0!==a&&a;var i=detector.events.ctx,e=detector.width/2,r=detector.height/2;i.save(),i.globalAlpha=this.alpha,i.strokeStyle=this.type.color,i.fillStyle=this.type.color,i.lineWidth=2,i.translate(e,r),i.rotate(this.direction),i.translate(-e,-r),i.beginPath(),i.arc(e+this.length/2,r+this.sign*Math.round(Math.sqrt(Math.abs(this.radius*this.radius-this.length*this.length/4))),this.radius,-this.sign*Math.PI/2-Math.asin(this.length/(2*this.radius)),-this.sign*Math.PI/2+Math.asin(this.length/(2*this.radius)),!1),i.stroke(),i.restore(),a||(this.alpha-=.03/16*t)};123