mjsoftware 909a14ffcc 优化:
调整主题颜色在高亮和暗黑模式下的颜色表现
评论插件传值方式
2024-03-12 08:17:23 +08:00

1 line
1.6 KiB
JavaScript

!function(){let i,e,t=document.body,n=window.innerWidth,o=window.innerHeight,s={x:n/2,y:n/2},h=[],a=[];function l(i){if(0<i.touches.length)for(let t=0;t<i.touches.length;t++)c(i.touches[t].clientX,i.touches[t].clientY,a[Math.floor(Math.random()*a.length)])}function c(t,i,e){h.push(new d(t,i,e))}function d(t,i,e){var n=Math.floor(60*Math.random()+60);this.initialLifeSpan=n,this.lifeSpan=n,this.velocity={x:(Math.random()<.5?-1:1)*(Math.random()/10),y:-1*Math.random()-.4},this.position={x:t,y:i},this.canv=e,this.baseDimension=4,this.update=function(t){this.position.x+=this.velocity.x,this.position.y+=this.velocity.y,this.velocity.x+=2*(Math.random()<.5?-1:1)/75,this.velocity.y-=Math.random()/600,this.lifeSpan--;var i=.2+(this.initialLifeSpan-this.lifeSpan)/this.initialLifeSpan;t.fillStyle="#e6f1f7",t.strokeStyle="#3a92c5",t.beginPath(),t.arc(this.position.x-this.baseDimension/2*i,this.position.y-this.baseDimension/2,this.baseDimension*i,0,2*Math.PI),t.stroke(),t.fill(),t.closePath()}}i=document.createElement("canvas"),e=i.getContext("2d"),i.style.top="0px",i.style.left="0px",i.style.pointerEvents="none",i.style.position="fixed",document.body.appendChild(i),i.width=n,i.height=o,t.addEventListener("mousemove",function(t){s.x=t.clientX,s.y=t.clientY,c(s.x,s.y)}),t.addEventListener("touchmove",l,{passive:!0}),t.addEventListener("touchstart",l,{passive:!0}),window.addEventListener("resize",function(t){n=window.innerWidth,o=window.innerHeight,i.width=n,i.height=o}),function t(){e.clearRect(0,0,n,o);for(let t=0;t<h.length;t++)h[t].update(e);for(let t=h.length-1;0<=t;t--)h[t].lifeSpan<0&&h.splice(t,1);requestAnimationFrame(t)}()}();