var u=class{constructor(t){this.fixedEnd=!0;this.fixedStart=!0;this.gradient=!1;this.outline=!1;this.map=(t,e,i,s,a)=>(t-e)*(a-s)/(i-e)+s;this.damp=(t,e,i)=>2*(1-e/t)*(e/t)*i;this.canvas=t.canvas,this.frequency=t.frequency,this.phase=t.phase,this.amplitude=t.amplitude,this.color=t.color,this.shift=t.shift,this.lineWidth=2,this.damping=t.damping,this.context=this.canvas.getContext("2d"),this.paused=!0,this.playbackSpeed=1,this.origin={x:0,y:this.canvas.height}}drawPoint(t,e,i){if(!this.context)return;let s=this.lineWidth/2;if(this.context.beginPath(),this.outline&&(this.context.fillStyle=i,this.context.lineWidth=2,this.context.arc(t,e,s,0,2*Math.PI),this.context.fill()),this.gradient){let a=this.context.createLinearGradient(0,0,0,this.canvas.height);a.addColorStop(.1,i),a.addColorStop(1,"transparent"),this.context.fillStyle=a}else this.context.fillStyle=i;this.context.fillRect(t-s,e-s,s,this.canvas.height-e+s)}buildSine(t,e,i,s,a){for(let n=this.origin.x,h=this.origin.x+t;n<h;n+=1){let r=s*Math.sin(a*(n+e));this.fixedStart&&this.fixedEnd?this.drawPoint(n,this.origin.y+this.damp(h,n,this.damping)*r,i):this.fixedStart?this.drawPoint(n,this.origin.y+this.map(n,this.origin.x,h,0,this.damping)*r,i):this.fixedEnd?this.drawPoint(n,this.origin.y+(this.damping-this.map(n,this.origin.x,h,0,this.damping))*r,i):this.drawPoint(n,this.origin.y+r,i)}}redraw(){this.phase+=this.shift*(this.paused?1:2*this.playbackSpeed),this.buildSine(this.canvas.width,this.phase,this.color,this.amplitude,this.frequency)}setPlay(){this.paused=!1}setPause(){this.paused=!0}setPlaybackSpeed(t){this.playbackSpeed=t}};export{u as a};
