/
t.htm
2 lines (2 loc) · 1.14 KB
/
t.htm
1
2
<canvas></canvas>
<script>w=window,d=document,c=d.querySelector("canvas"),cx=c.getContext("2d"),c.width=w.innerWidth,c.height=w.innerHeight,e=[],ma=100,mx=0,my=0,f=0,h=1,o=null,r=(()=>{ma=(ma+Math.PI/360)%(2*Math.PI),mx=c.width/2+10*Math.cos(10*ma),my=c.height/2+50*Math.sin(10*ma),f+=h,o&&(o.frequency.value=30*-my),e.push({x:mx,y:my,scale:5});for(var t=0;t<=e.length-1;t++)t==e.length-1?drawStar(e[t].x,e[t].y,5,5,12):(e[t].scale+=e[t].scale/13,cx.beginPath(),cx.arc(e[t].x,e[t].y,e[t].scale,0,2*Math.PI,!1),cx.fillStyle="#fff",cx.fill(),cx.lineWidth=1,cx.strokeStyle="hsl("+t/f*900+", 50%,70%)",cx.stroke());e.length>70&&e.shift(),f>70&&(h=-1),f<=0&&(h=1),w.requestAnimationFrame(r)}),drawStar=((e,t,c,a,h)=>{var l=Math.PI/2*3,n=e,o=t,x=Math.PI/c;for(cx.beginPath(),cx.moveTo(e,t-a),i=0;i<c;i++)n=e+Math.cos(l)*a,o=t+Math.sin(l)*a,cx.lineTo(n,o),l+=x,n=e+Math.cos(l)*h,o=t+Math.sin(l)*h,cx.lineTo(n,o),l+=x;cx.lineTo(e,t-a),cx.closePath(),cx.lineWidth=2,cx.strokeStyle="686735",cx.stroke(),cx.fillStyle="fdfb56",cx.fill()}),s=0,d.addEventListener("click",e=>{1!=s&&(ax=new AudioContext,o=ax.createOscillator(),o.connect(ax.destination),o.start(),s=1)}),r();</script>