mirror of
https://github.com/SouthFox-D/SouthFox-D.github.io.git
synced 2024-11-29 18:05:34 +01:00
2 lines
27 KiB
JavaScript
2 lines
27 KiB
JavaScript
|
var cursoreffects=function(t){"use strict";return t.bubbleCursor=function(t){let e,i,n,o=t&&t.element,s=o||document.body,h=window.innerWidth,c=window.innerHeight,l={x:h/2,y:h/2},d=[],a=[];const r=window.matchMedia("(prefers-reduced-motion: reduce)");function A(){if(r.matches)return console.log("This browser has prefers reduced motion turned on, so the cursor did not init"),!1;e=document.createElement("canvas"),i=e.getContext("2d"),e.style.top="0px",e.style.left="0px",e.style.pointerEvents="none",o?(e.style.position="absolute",s.appendChild(e),e.width=s.clientWidth,e.height=s.clientHeight):(e.style.position="fixed",document.body.appendChild(e),e.width=h,e.height=c),s.addEventListener("mousemove",g),s.addEventListener("touchmove",m,{passive:!0}),s.addEventListener("touchstart",m,{passive:!0}),window.addEventListener("resize",u),f()}function u(t){h=window.innerWidth,c=window.innerHeight,o?(e.width=s.clientWidth,e.height=s.clientHeight):(e.width=h,e.height=c)}function m(t){if(t.touches.length>0)for(let e=0;e<t.touches.length;e++)p(t.touches[e].clientX,t.touches[e].clientY,a[Math.floor(Math.random()*a.length)])}function g(t){if(o){const e=s.getBoundingClientRect();l.x=t.clientX-e.left,l.y=t.clientY-e.top}else l.x=t.clientX,l.y=t.clientY;p(l.x,l.y)}function p(t,e,i){d.push(new y(t,e,i))}function f(){!function(){i.clearRect(0,0,h,c);for(let t=0;t<d.length;t++)d[t].update(i);for(let t=d.length-1;t>=0;t--)d[t].lifeSpan<0&&d.splice(t,1)}(),n=requestAnimationFrame(f)}function y(t,e,i){const 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:e},this.canv=i,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--;const e=.2+(this.initialLifeSpan-this.lifeSpan)/this.initialLifeSpan;t.fillStyle="#e6f1f7",t.strokeStyle="#3a92c5",t.beginPath(),t.arc(this.position.x-this.baseDimension/2*e,this.position.y-this.baseDimension/2,this.baseDimension*e,0,2*Math.PI),t.stroke(),t.fill(),t.closePath()}}r.onchange=()=>{r.matches?this.destroy():A()},this.destroy=()=>{e.remove(),cancelAnimationFrame(n),s.removeEventListener("mousemove",g),s.removeEventListener("touchmove",m),s.removeEventListener("touchstart",m),window.addEventListener("resize",u)},A()},t.clockCursor=function(t){let e,i,n,o=t&&t.element,s=o||document.body,h=window.innerWidth,c=window.innerHeight,l={x:h/2,y:h/2};const d=t&&t.dateColor||"blue",a=t&&t.faceColor||"black",r=t&&t.secondsColor||"red",A=t&&t.minutesColor||"black",u=t&&t.hoursColor||"black",m=.4;let g=new Date,p=g.getDate(),f=g.getYear()+1900;const y=(" "+["SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY"][g.getDay()]+" "+p+" "+["JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"][g.getMonth()]+" "+f).split(""),v=["3","4","5","6","7","8","9","10","11","12","1","2"],w=v.length,x=["•","•","•"],E=["•","•","•","•"],C=["•","•","•","•","•"],M=360/w,L=360/y.length,B=45/6.5,b=[],R=[],Y=[],S=[],W=[],H=[],I=[],X=[],T=[];var D=parseInt(y.length+w+x.length+E.length+C.length)+1;const F=window.matchMedia("(prefers-reduced-motion: reduce)");function z(){if(F.matches)return console.log("This browser has prefers reduced motion turned on, so the cursor did not init"),!1;e=document.createElement("canvas"),i=e.getContext("2d"),e.style.top="0px",e.style.left="0px",e.style.pointerEvents="none",o?(e.style.position="absolute",s.appendChild(e),e.width=s.clientWidth,e.height=s.clientHeight):(e.style.position="fixed",document.body.appendChild(e),e.width=h,e.height=c),i.font="10px sans-serif",i.textAlign="center",i.textBaseline="middle";for(let t=0;t<D;t++)b[t]=0,R[t]=0,Y[t]=0,S[t]=0;for(let t=0;t<y.length;t++)T[t]={color:d,value:y[t]};for(let t=0;t<v.length;t++)X[t]={color:a,value:v[t]};for(let t=0;t<x.length;t++)I[t]={color:u,value:x[t]};for(let t=0;t<E.length;t++)H[t]={color:A,
|