-
Notifications
You must be signed in to change notification settings - Fork 1
/
wojchan.min.js
1 lines (1 loc) · 894 Bytes
/
wojchan.min.js
1
(()=>{let a=document.createElement("canvas"),o=30,d=(a.id="wojchan",a.width=a.height=2*(o+1),a.style="position:fixed;pointer-events:none;image-rendering:pixelated;z-index:"+Number.MAX_VALUE,document.body.appendChild(a),a.getContext("2d")),s=(d.imageSmoothingEnabled=!1,{x:window.innerWidth/2,y:window.innerHeight/2}),r={...s},n=(window.addEventListener("mousemove",e=>r={x:e.clientX,y:e.clientY}),new Image(3*o,3*o)),c=(n.src="https://cdn.jsdelivr.net/gh/wojtekcodestoday/wojchan@master/sprite.png",(e,t)=>{d.drawImage(n,e*o,t*o,o,o,0,0,o,o)}),h=0,l=(d.scale(2,2),()=>{var e=r.x-s.x,t=r.y-s.y,n=Math.sqrt(e*e+t*t),t=Math.atan2(t,e),e=Math.cos(t)<0,i=(d.clearRect(0,0,2*o,2*o),150<n?8:4);a.style.left=s.x-o+"px",a.style.top=s.y-o+"px",c(0,2),c(15<n?3==h||h:1,e),8==i&&c(1+!e,2),15<n&&(h=(h+1)%4,s.x+=Math.cos(t)*i,s.y+=Math.sin(t)*i),setTimeout(()=>requestAnimationFrame(l),70)});n.onload=l})();