This commit is contained in:
杜恒
2021-01-25 11:29:51 +08:00
parent 7d49bfe1cb
commit fd21fc6a49
15 changed files with 1888 additions and 1698 deletions

View File

@@ -0,0 +1 @@
!function(){function t(){let t=document.getElementsByTagName("script"),e=t.length,n=t[e-1];return{length:e,z:-1000,opacity:n.getAttribute("opacity")||.5,color:n.getAttribute("color")||"0,0,0",count:n.getAttribute("count")||99}}function e(){W=i.width=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,H=i.height=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}function n(){o.clearRect(0,0,W,H);var t,e,i=[y].concat(d);d.forEach(function(n){n.x+=n.xa,n.y+=n.ya,n.xa=n.xa*(n.x>W||n.x<0?-1:1),n.ya=n.ya*(n.y>H||n.y<0?-1:1),o.fillRect(n.x-.5,n.y-.5,1,1);for(let c=0;c<i.length;c++)t=i[c],n!==t&&null!==t.x&&null!==t.y&&(x_diff=n.x-t.x,y_diff=n.y-t.y,distance=x_diff*x_diff+y_diff*y_diff,distance<t.max&&(t===y&&distance>t.max/2&&(n.x=n.x-.03*x_diff,n.y=n.y-.03*y_diff),e=(t.max-distance)/t.max,o.beginPath(),o.lineWidth=e/2,o.strokeStyle="rgba("+a.color+","+(e+.2)+")",o.moveTo(n.x,n.y),o.lineTo(t.x,t.y),o.stroke()));i.splice(i.indexOf(n),1)}),r(n)}var i=document.createElement("canvas"),o=i.getContext("2d"),a=t();i.id="c_n"+a.length,i.style.cssText="position:fixed;top:0;left:0;z-index:"+a.z+";opacity:"+a.opacity,document.getElementsByTagName("body")[0].appendChild(i),e(),window.onresize=e;var c=Math.random,d=[];for(let t=0;t<a.count;t++){var l=c()*W,u=c()*H,m=2*c()-1,x=2*c()-1;d.push({x:l,y:u,xa:m,ya:x,max:6e3})}var y={x:null,y:null,max:2e4};window.onmousemove=function(t){t=t||window.event,y.x=t.clientX,y.y=t.clientY},window.onmouseout=function(){y.x=null,y.y=null};var r=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/45)};setTimeout(function(){n()},100)}();

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
function animate(a=0){const t=a>=finish+arcStagger*colors.length;let e=window.innerWidth*DPR,n=window.innerHeight*DPR;const o=.5*n/colors.length,i=e/2,r=n+o*rainbowHeight+(n-colors.length*o)/3,l=e/2+colors.length*o*2,s=n;let c=document.getElementById("rainbow").getContext("2d");c.clearRect(0,0,e,n),c.globalAlpha=1,c.lineWidth=o;for(let e=colors.length-1;e>-1;e--){const[n,d]=colors[e],h=r+e*(o/2-1),m=l-e*o/2,f=s-e*o/2,g=tau*(a-e*arcStagger)+start,u=clamp(start,tau*finish+start,g);if(c.beginPath(),c.shadowColor=n,c.strokeStyle=n,c.ellipse(i,h,m,f,0,start,u,!1),c.lineCap="round",c.stroke(),c.closePath(),t)sparkles.push(makeSparkle({cx:i,cy:h,radiusX:m,radiusY:f,endAngle:Math.random()*Math.PI+Math.PI,lineWidth:o,color:boolRandom()?"#fff":d}));else for(let a=0;a<sparklesInPerStripe;a++)sparkles.push(makeSparkle({cx:i,cy:h,radiusX:m,radiusY:f,endAngle:u,lineWidth:o,color:n}))}const d=[];for(let a=0,t=sparkles.length;a<t;a++){const{x:t,y:e,opacity:n,color:o,rad:i}=sparkles[a];c.beginPath(),c.globalAlpha=n,c.fillStyle=o,c.arc(t-i,e-i,i,0,Math.PI/2),c.arc(t-i,e+i,i,3*Math.PI/2,2*Math.PI),c.arc(t+i,e+i,i,Math.PI,3*Math.PI/2),c.arc(t+i,e-i,i,Math.PI/2,Math.PI),c.fill(),n>.2&&i>.2&&d.push({x:t,y:e,opacity:n-.03,rad:i-.2,color:o})}sparkles=d,t?requestAnimationFrame(function(){animate(finish+colors.length*arcStagger)}):requestAnimationFrame(function(){animate(a+inc)})}let canvasDom=document.createElement("canvas");canvasDom.setAttribute("id","rainbow"),canvasDom.setAttribute("style","background-color: #ffffffe0;z-index: -1000;position:fixed;top:0;left:0;right:0;bottom:0;"),document.body.appendChild(canvasDom);const DPR=window.devicePixelRatio,colors=[["#EC008C","#f957b6"],["#EF4136","#ff7972"],["yellow","#fff"],["lime","#7aff7a"],["#27AAE1","#5ec8f2"],["#662D91","#a158d8"]],tau=2*Math.PI,start=Math.PI,finish=.5,inc=.007,rainbowHeight=.5,arcStagger=.05,sparklesInPerStripe=3;let sparkles=[];const clamp=(a,t,e)=>Math.min(Math.max(a,e),t),boolRandom=()=>!Math.round(Math.random()),sizeCanvas=()=>{radius=clamp(15,50,window.innerWidth/60/DPR);const a=document.getElementById("rainbow");a.width=window.innerWidth*DPR,a.height=window.innerHeight*DPR},addRandom=function(a){return(boolRandom()?-1:1)*Math.random()*a},makeSparkle=({cx:a,cy:t,radiusX:e,radiusY:n,endAngle:o,lineWidth:i,color:r})=>({x:a+e*Math.cos(o)+addRandom(i),y:t+n*Math.sin(o)+addRandom(i),opacity:1,color:r,rad:Math.max(radius*Math.random()*DPR,15)});sizeCanvas(),requestAnimationFrame(function(){animate()}),window.addEventListener("resize",sizeCanvas);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
!function(){function e(e,t,n){return Number(e.getAttribute(t))||n}function t(){for(r.clearRect(0,0,h,s),a=[{x:0,y:.7*s+f},{x:0,y:.7*s-f}];a[1].x<h+f;)n(a[0],a[1])}function n(e,t){r.beginPath(),r.moveTo(e.x,e.y),r.lineTo(t.x,t.y);var n=t.x+(2*p()-.25)*f,o=i(t.y);r.lineTo(n,o),r.closePath(),m-=x/-50,r.fillStyle="#"+(127*y(m)+128<<16|127*y(m+x/3)+128<<8|127*y(m+x/3*2)+128).toString(16),r.fill(),a[0]=a[1],a[1]={x:n,y:o}}function i(e){return l=e+(2*p()-1.1)*f,l>s||l<0?i(e):l}var o=document.getElementsByTagName("script"),c=o[o.length-1];config={z:e(c,"zIndex",-1000),a:e(c,"alpha",.6),s:e(c,"size",90)};var a,l,d=document.createElement("canvas"),r=d.getContext("2d"),g=window.devicePixelRatio||1,h=window.innerWidth,s=window.innerHeight,f=config.s,u=Math,m=0,x=2*u.PI,y=u.cos,p=u.random;d.width=h*g,d.height=s*g,r.scale(g,g),r.globalAlpha=config.a,d.style.cssText="opacity: "+config.a+";position:fixed;top:0;left:0;z-index: "+config.z+";width:100%;height:100%;pointer-events:none;",document.getElementsByTagName("body")[0].appendChild(d),document.onclick=t,document.ontouchstart=t,t()}();