whisper.cat/weboasis/weather/js/skycons.min.js
2023-10-05 23:28:32 +11:00

1 line
7.8 KiB
JavaScript

!function(t){"use strict";var n,i,e,a;e=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame,a=t.cancelAnimationFrame||t.webkitCancelAnimationFrame||t.mozCancelAnimationFrame||t.oCancelAnimationFrame||t.msCancelAnimationFrame,e&&a?(n=function(n){var i={value:null};return function t(){i.value=e(t),n()}(),i},i=function(t){a(t.value)}):(n=setInterval,i=clearInterval);var d=.08,I=2*Math.PI,u=2/Math.sqrt(2);function b(t,n,i,e,a){t.beginPath(),t.moveTo(n,i),t.lineTo(e,a),t.stroke()}function h(t,n,i,e,a,o,r,l){var s,h,c,u,v=Math.cos(n*I),f=Math.sin(n*I);h=i-f*a,c=e+v*o+.5*(l-=r),u=r+(1-.5*v)*l,(s=t).beginPath(),s.arc(h,c,u,0,I,!1),s.fill()}function m(t,n,i,e,a,o,r,l){var s;for(s=5;s--;)h(t,n+s/5,i,e,a,o,r,l)}function r(t,n,i,e,a,o,r){n/=3e4;var l=.21*a,s=.12*a,h=.24*a,c=.28*a;t.fillStyle=r,m(t,n,i,e,l,s,h,c),t.globalCompositeOperation="destination-out",m(t,n,i,e,l,s,h-o,c-o),t.globalCompositeOperation="source-over"}function l(t,n,i,e,a,o,r){n/=12e4;var l,s,h,c,u=.25*a-.5*o,v=.32*a+.5*o,f=.5*a-.5*o;for(t.strokeStyle=r,t.lineWidth=o,t.lineCap="round",t.lineJoin="round",t.beginPath(),t.arc(i,e,u,0,I,!1),t.stroke(),l=8;l--;)s=(n+l/8)*I,b(t,i+(h=Math.cos(s))*v,e+(c=Math.sin(s))*v,i+h*f,e+c*f)}function s(t,n,i,e,a,o,r){n/=15e3;var l=.29*a-.5*o,s=.05*a,h=Math.cos(n*I),c=h*I/-16;t.strokeStyle=r,t.lineWidth=o,t.lineCap="round",t.lineJoin="round",i+=h*s,t.beginPath(),t.arc(i,e,l,c+I/8,c+7*I/8,!1),t.arc(i+Math.cos(c)*l*u,e+Math.sin(c)*l*u,l,c+5*I/8,c+3*I/8,!0),t.closePath(),t.stroke()}var O=[[-.75,-.18,-.7219,-.1527,-.6971,-.1225,-.6739,-.091,-.6516,-.0588,-.6298,-.0262,-.6083,.0065,-.5868,.0396,-.5643,.0731,-.5372,.1041,-.5033,.1259,-.4662,.1406,-.4275,.1493,-.3881,.153,-.3487,.1526,-.3095,.1488,-.2708,.1421,-.2319,.1342,-.1943,.1217,-.16,.1025,-.129,.0785,-.1012,.0509,-.0764,.0206,-.0547,-.012,-.0378,-.0472,-.0324,-.0857,-.0389,-.1241,-.0546,-.1599,-.0814,-.1876,-.1193,-.1964,-.1582,-.1935,-.1931,-.1769,-.2157,-.1453,-.229,-.1085,-.2327,-.0697,-.224,-.0317,-.2064,.0033,-.1853,.0362,-.1613,.0672,-.135,.0961,-.1051,.1213,-.0706,.1397,-.0332,.1512,.0053,.158,.0442,.1624,.0833,.1636,.1224,.1615,.1613,.1565,.1999,.15,.2378,.1402,.2749,.1279,.3118,.1147,.3487,.1015,.3858,.0892,.4236,.0787,.4621,.0715,.5012,.0702,.5398,.0766,.5768,.089,.6123,.1055,.6466,.1244,.6805,.144,.7147,.163,.75,.18],[-.75,0,-.7033,.0195,-.6569,.0399,-.6104,.06,-.5634,.0789,-.5155,.0954,-.4667,.1089,-.4174,.1206,-.3676,.1299,-.3174,.1365,-.2669,.1398,-.2162,.1391,-.1658,.1347,-.1157,.1271,-.0661,.1169,-.017,.1046,.0316,.0903,.0791,.0728,.1259,.0534,.1723,.0331,.2188,.0129,.2656,-.0064,.3122,-.0263,.3586,-.0466,.4052,-.0665,.4525,-.0847,.5007,-.1002,.5497,-.113,.5991,-.124,.6491,-.1325,.6994,-.138,.75,-.14]],D=[{start:.36,end:.11},{start:.56,end:.16}];function c(t,n,i,e,a,o,r,l,s){var h,c,u,v,f,d,m,g,M,p,C,w,y,b,k,A,P=O[r],T=((n/=2500)+r-D[r].start)%l,F=(n+r-D[r].end)%l,S=(n+r)%l;if(t.strokeStyle=s,t.lineWidth=o,t.lineCap="round",t.lineJoin="round",T<1){if(t.beginPath(),T*=P.length/2-1,T-=h=Math.floor(T),h*=2,h+=2,t.moveTo(i+(P[h-2]*(1-T)+P[h]*T)*a,e+(P[h-1]*(1-T)+P[h+1]*T)*a),F<1){for(F*=P.length/2-1,F-=c=Math.floor(F),c*=2,c+=2,v=h;v!==c;v+=2)t.lineTo(i+P[v]*a,e+P[v+1]*a);t.lineTo(i+(P[c-2]*(1-F)+P[c]*F)*a,e+(P[c-1]*(1-F)+P[c+1]*F)*a)}else for(v=h;v!==P.length;v+=2)t.lineTo(i+P[v]*a,e+P[v+1]*a);t.stroke()}else if(F<1){for(t.beginPath(),F*=P.length/2-1,F-=c=Math.floor(F),c*=2,c+=2,t.moveTo(i+P[0]*a,e+P[1]*a),v=2;v!==c;v+=2)t.lineTo(i+P[v]*a,e+P[v+1]*a);t.lineTo(i+(P[c-2]*(1-F)+P[c]*F)*a,e+(P[c-1]*(1-F)+P[c+1]*F)*a),t.stroke()}S<1&&(S*=P.length/2-1,S-=u=Math.floor(S),u*=2,f=t,d=n,m=i+(P[(u+=2)-2]*(1-S)+P[u]*S)*a,g=e+(P[u-1]*(1-S)+P[u+1]*S)*a,M=o,p=s,y=2*(w=(C=a/8)/3),b=d%1*I,k=Math.cos(b),A=Math.sin(b),f.fillStyle=p,f.strokeStyle=p,f.lineWidth=M,f.lineCap="round",f.lineJoin="round",f.beginPath(),f.arc(m,g,C,b,b+Math.PI,!1),f.arc(m-w*k,g-w*A,y,b+Math.PI,b,!1),f.arc(m+y*k,g+y*A,w,b+Math.PI,b,!0),f.globalCompositeOperation="destination-out",f.fill(),f.globalCompositeOperation="source-over",f.stroke())}var o=function(t){this.list=[],this.interval=null,this.color=t&&t.color?t.color:"black",this.resizeClear=!(!t||!t.resizeClear)};o.CLEAR_DAY=function(t,n,i){var e=t.canvas.width,a=t.canvas.height,o=Math.min(e,a);l(t,n,.5*e,.5*a,o,o*d,i)},o.CLEAR_NIGHT=function(t,n,i){var e=t.canvas.width,a=t.canvas.height,o=Math.min(e,a);s(t,n,.5*e,.5*a,o,o*d,i)},o.PARTLY_CLOUDY_DAY=function(t,n,i){var e=t.canvas.width,a=t.canvas.height,o=Math.min(e,a);l(t,n,.625*e,.375*a,.75*o,o*d,i),r(t,n,.375*e,.625*a,.75*o,o*d,i)},o.PARTLY_CLOUDY_NIGHT=function(t,n,i){var e=t.canvas.width,a=t.canvas.height,o=Math.min(e,a);s(t,n,.667*e,.375*a,.75*o,o*d,i),r(t,n,.375*e,.625*a,.75*o,o*d,i)},o.CLOUDY=function(t,n,i){var e=t.canvas.width,a=t.canvas.height,o=Math.min(e,a);r(t,n,.5*e,.5*a,o,o*d,i)},o.RAIN=function(t,n,i){var e=t.canvas.width,a=t.canvas.height,o=Math.min(e,a);!function(t,n,i,e,a,o,r){n/=1350;var l,s,h,c,u=.16*a,v=11*I/12,f=7*I/12;for(t.fillStyle=r,l=4;l--;)h=i+(l-1.5)/1.5*(1===l||2===l?-1:1)*u,c=e+(s=(n+l/4)%1)*s*a,t.beginPath(),t.moveTo(h,c-1.5*o),t.arc(h,c,.75*o,v,f,!1),t.fill()}(t,n,.5*e,.37*a,.9*o,o*d,i),r(t,n,.5*e,.37*a,.9*o,o*d,i)},o.SLEET=function(t,n,i){var e=t.canvas.width,a=t.canvas.height,o=Math.min(e,a);!function(t,n,i,e,a,o,r){n/=750;var l,s,h,c,u=.1875*a;for(t.strokeStyle=r,t.lineWidth=.5*o,t.lineCap="round",t.lineJoin="round",l=4;l--;)s=(n+l/4)%1,b(t,h=Math.floor(i+(l-1.5)/1.5*(1===l||2===l?-1:1)*u)+.5,(c=e+s*a)-1.5*o,h,c+1.5*o)}(t,n,.5*e,.37*a,.9*o,o*d,i),r(t,n,.5*e,.37*a,.9*o,o*d,i)},o.SNOW=function(t,n,i){var e=t.canvas.width,a=t.canvas.height,o=Math.min(e,a);!function(t,n,i,e,a,o,r){var l,s,h,c,u=.16*a,v=.75*o,f=(n/=3e3)*I*.7,d=Math.cos(f)*v,m=Math.sin(f)*v,g=f+I/3,M=Math.cos(g)*v,p=Math.sin(g)*v,C=f+2*I/3,w=Math.cos(C)*v,y=Math.sin(C)*v;for(t.strokeStyle=r,t.lineWidth=.5*o,t.lineCap="round",t.lineJoin="round",l=4;l--;)s=(n+l/4)%1,b(t,(h=i+Math.sin((s+l/4)*I)*u)-d,(c=e+s*a)-m,h+d,c+m),b(t,h-M,c-p,h+M,c+p),b(t,h-w,c-y,h+w,c+y)}(t,n,.5*e,.37*a,.9*o,o*d,i),r(t,n,.5*e,.37*a,.9*o,o*d,i)},o.WIND=function(t,n,i){var e=t.canvas.width,a=t.canvas.height,o=Math.min(e,a);c(t,n,.5*e,.5*a,o,o*d,0,2,i),c(t,n,.5*e,.5*a,o,o*d,1,2,i)},o.FOG=function(t,n,i){var e=t.canvas.width,a=t.canvas.height,o=Math.min(e,a),r=o*d;!function(t,n,i,e,a,o,r){n/=3e4;var l=.21*a,s=.06*a,h=.21*a,c=.28*a;t.fillStyle=r,m(t,n,i,e,l,s,h,c),t.globalCompositeOperation="destination-out",m(t,n,i,e,l,s,h-o,c-o),t.globalCompositeOperation="source-over"}(t,n,.5*e,.32*a,.75*o,r,i),n/=5e3;var l=Math.cos(n*I)*o*.02,s=Math.cos((n+.25)*I)*o*.02,h=Math.cos((n+.5)*I)*o*.02,c=Math.cos((n+.75)*I)*o*.02,u=.936*a,v=Math.floor(u-.5*r)+.5,f=Math.floor(u-2.5*r)+.5;t.strokeStyle=i,t.lineWidth=r,t.lineCap="round",t.lineJoin="round",b(t,l+.2*e+.5*r,v,s+.8*e-.5*r,v),b(t,h+.2*e+.5*r,f,c+.8*e-.5*r,f)},o.prototype={_determineDrawingFunction:function(t){return"string"==typeof t&&(t=o[t.toUpperCase().replace(/-/g,"_")]||null),t},add:function(t,n){var i;"string"==typeof t&&(t=document.getElementById(t)),null!==t&&"function"==typeof(n=this._determineDrawingFunction(n))&&(i={element:t,context:t.getContext("2d"),drawing:n},this.list.push(i),this.draw(i,500))},set:function(t,n){var i;for("string"==typeof t&&(t=document.getElementById(t)),i=this.list.length;i--;)if(this.list[i].element===t)return this.list[i].drawing=this._determineDrawingFunction(n),void this.draw(this.list[i],500);this.add(t,n)},remove:function(t){var n;for("string"==typeof t&&(t=document.getElementById(t)),n=this.list.length;n--;)if(this.list[n].element===t)return void this.list.splice(n,1)},draw:function(t,n){var i=t.context.canvas;this.resizeClear?i.width=i.width:t.context.clearRect(0,0,i.width,i.height),t.drawing(t.context,n,this.color)},play:function(){var i=this;this.pause(),this.interval=n(function(){var t,n=Date.now();for(t=i.list.length;t--;)i.draw(i.list[t],n)},1e3/60)},pause:function(){this.interval&&(i(this.interval),this.interval=null)}},t.Skycons=o}(this);