-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdweetdiv.min.js
1 lines (1 loc) · 2.51 KB
/
dweetdiv.min.js
1
"use strict";function addDweet(e,t,n){const i=void 0===(null==n?void 0:n.fps)?60:n.fps,o=void 0===(null==n?void 0:n.intermediateDraws)?Math.max(1,Math.ceil(i/60)):null==n?void 0:n.intermediateDraws,r=(e,t)=>{if("number"!=typeof i||isNaN(i))throw new TypeError(e+"has to be a number that is also not NaN")};if(r("fps"),r("intermediateDraws"),i<0)throw new RangeError("fps has to be greater or equal to 0");if(o<=0||o!==Math.floor(o))throw new RangeError("drawIntermediate has to be integer greater than 0 or Infinity");if("string"!=typeof t)throw new TypeError("type of code has to be a string");const a=o!==1/0;let d=0;const l=i===1/0,s=document.getElementById(e);if(null===s)throw new Error("couldn't find div to put the canvas (did you get the id wrong?)");let c=!1;document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&(c=!0)});const h=()=>{const e=document.createElement("div");return e.style.width="100%",e.style.backgroundColor="black",e.style.color="white",e.style.padding="4px",e.style.boxSizing="border-box",e.style.fontFamily="monospace",e.style.wordBreak="break-all",e};if(null==n?void 0:n.credits){var u,m,f;const e=h(),t=null===(u=n.credits)||void 0===u?void 0:u.title,i=null===(m=n.credits)||void 0===m?void 0:m.author,o=null===(f=n.credits)||void 0===f?void 0:f.link,r=document.createElement("span");if(r.innerText="/* "+(t?" "+t:"")+(i?" by "+i:""),e.appendChild(r),o){r.innerText+=" ";const t=document.createElement("a");t.innerText=o,t.href=o,t.style.color="#aaaaaa",e.appendChild(t)}const a=document.createElement("span");a.innerText=" */",e.appendChild(a),s.appendChild(e)}const p=Math.cos,w=Math.sin,y=Math.tan,v=(e,t,n,i=1)=>`rgba(${0|e},${0|t},${0|n},${i})`,g=document.createElement("canvas");g.width=1920,g.height=1080,g.style.width="100%";const b=document.createElement("div");b.style.width="100%",b.style.height="0",b.style.paddingBottom="56.25%",b.style.overflow="hidden",b.appendChild(g),s.appendChild(b);const E=g.getContext("2d");let C=new Function("t","c","x","R","C","S","T",t);if(null==n?void 0:n.showCode){const e=h();e.innerText=t,s.appendChild(e)}let x=0,M=0,T=1;const k=e=>{c&&(c=!1,x+=e-M,M=e,requestAnimationFrame(k));let t=(e-x)/1e3;if((()=>{const e=g.getBoundingClientRect();return e.left<window.innerWidth&&e.right>0&&e.top<window.innerHeight&&e.bottom>0})()){if(!l)if(0===i)T=1;else if(t>=d/i){const e=Math.floor(t*i-d);T=Math.min(e,o),x+=(e-T)/i*1e3,d+=T}if(a)for(let e=0;e<T;e++)C((d+(e-T))/i,g,E,v,p,w,y);else T&&C(t,g,E,v,p,w,y);if(0===i)return}else x+=e-M;M=e,requestAnimationFrame(k)};k(0)}