-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwojchan.min.js
More file actions
1 lines (1 loc) · 862 Bytes
/
wojchan.min.js
File metadata and controls
1 lines (1 loc) · 862 Bytes
1
(()=>{let a=document.createElement("canvas"),o=30,d=(a.id="wojchan",a.width=a.height=2*(o+1),document.body.appendChild(a),a.getContext("2d")),s=(d.imageSmoothingEnabled=!1,{x:window.innerWidth/2,y:window.innerHeight/2}),r={...s},n=(window.onmousemove=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,m=(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=`position:fixed;pointer-events:none;image-rendering:pixelated;z-index:${Number.MAX_VALUE};left:${s.x-o}px;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(m),70)});n.onload=m})();