halo-theme-dream2.0-plus
Version:
梦之城,童话梦境,动漫类型博客主题。
1 lines • 1.78 kB
JavaScript
!function(){function e(){l.width=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,l.height=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}function n(){var a,m,c,d;u.clearRect(0,0,l.width,l.height),r.forEach(function(e,n){e.x+=e.vx,e.y+=e.vy,e.vx*=e.x>l.width||e.x<0?-1:1,e.vy*=e.y>l.height||e.y<0?-1:1,u.fillRect(e.x-.5,e.y-.5,1,1);for(var t,i,o=n+1;o<s.length;o++)null!==(a=s[o]).x&&null!==a.y&&(d=e.x-a.x,c=e.y-a.y,(m=d*d+c*c)<a.maxDistance)&&(a===h&&m>=a.maxDistance/2&&(e.x-=.03*d,e.y-=.03*c),d=(a.maxDistance-m)/a.maxDistance,u.beginPath(),u.lineWidth=d/2,u.strokeStyle=(t=d,i=void 0,(i=localStorage.getItem("special-efficacy-scheme"))&&"dark"===i?`rgba(200, 200, 200, ${Math.min(t+.2,1)})`:`rgba(100, 100, 100, ${Math.min(t+.2,1)})`),u.moveTo(e.x,e.y),u.lineTo(a.x,a.y),u.stroke())}),requestAnimationFrame(n)}var t=DreamConfig.effects_quantum_silk_thread_mode,i=document.documentElement.classList.contains("night");if("all"===t||"day"===t&&!i||"night"===t&&i){var l=document.createElement("canvas"),t=-1,i=.5,o=99,u=l.getContext("2d"),h=(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame,{x:null,y:null,maxDistance:2e4});l.id="quantum_c_n",l.style.cssText="position:fixed;top:0;left:0;z-index:"+t+";opacity:"+i,document.body.appendChild(l),e(),window.onresize=e,window.onmousemove=function(e){e=e||window.event,h.x=e.clientX,h.y=e.clientY},window.onmouseout=function(){h.x=null,h.y=null};for(var r=[],a=0;a<o;a++)r.push({x:Math.random()*l.width,y:Math.random()*l.height,vx:2*Math.random()-1,vy:2*Math.random()-1,maxDistance:6e3});var s=r.concat([h]);setTimeout(function(){n()},100)}}();