hunter paulson
donut.js
2025-10-15
|
||||
| blog | projects | github | ||
this is my attempt to recreate aikon’s donut.c animation on the web with obfuscated javascript.
(()=>{w=80;;h=
45;l=".,-~:;=!*#$@";A
=B=0;setInterval(_=>{s =(
document.getElementById("d"));
if(!s)return;z=[];b=[];A+=.07;B+=
.03;cA=Math.cos(A);sA=Math.sin(A);cB=
Math.cos(B);sB=Math.sin(B);for(j=0;j<
6.28;j+=.07){cT=Math.cos(j);sT=Math.sin
(j);for(i=0;i<6.2 ;i+=.02){sP=Math
.sin(i);cP=Math. cos(i);H=cT+2;I
=1/(sP*H*sA+sT* cA+5);;t=sP*H*
cA-sT*sA;;x=w/2+ w*.375*I*(cP*H*
cB-t*sB)|0;;;;y=h /2+h*.35*I*(cP*H
*sB+t*cB)|0;if(x>=0&&x<w&&y>=0&&y<h&&I
>(z[o=x+w*y]||0)){N=8*((sT*sA-sP*cT*cA
)*cB-sP*cT*sA-sT*cA-cP*cT*sB)|0;z[o]
=I;b[o]=l[N<0?0:N]}}}for(o="",k=0
;k<w*h;k++)o+=b[k]||"\x20",k%w
==w-1&&k<w*h-1&&(o+="\n");
s.textContent=o},50)})
();;;;;;;;;;;;here is proof that the above code renders the torus below
(loading donut...)
try ‘debug mode’ below