- Author:
- Aki Jäntti
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- Compo:
- classic
- Demo link:
- https://js1k.com/2010-first/demo/729
- Shortlink:
- https://js1k.com/729
- Blog post:
- please update here!
- Bytes:
- 1024
- Chars:
- 1024
- Submission
M=Math;R=128;K=R*R;Z=K*R;c=document.body.children[0];c.width=R*4;c.height=R*2;c.style.border="2px solid #000";H=c.getContext("2d");a=[];for(i=Z;i--;)a[i]=M.random();F=32;C=[];for(i=F;i--;)C[i]=(1-M.cos(i/F*M.PI))/2;U=F;for(f=2;f<64;f*=2){U/=2;for(z=0;z<R;z+=f){A=z<R-f?z+f:0;for(y=0;y<R;y+=f){O=y<R-f?y+f:0;for(x=0;x<R;x+=f){L=x<R-f?x+f:0;for(i=f;i--;)for(j=f;j--;)for(k=f;k--;){Q=C[j*U];W=C[i*U];E=C[k*U];J=z*K+k*K+y*R+j*R+x+i;T=1-W;B=z*K;N=A*K;Y=y*R;V=O*R;a[J]=a[J]/2+(((a[B+Y+x]*T+a[B+Y+L]*W)*(1-Q)+(a[B+V+x]*T+a[B+V+L]*W)*Q)*(1-E)+((a[N+Y+x]*T+a[N+Y+L]*W)*(1-Q)+(a[N+V+x]*T+a[N+V+L]*W)*Q)*E)/2}}}}}for(i=Z;i--;){k=a[i];k=k>0.5?0.5:k<0.3?0.3:k;a[i]=~~(255*M.cos((k*5-1.5)/2*M.PI))}I=H.getImageData(0,0,R*4,R);D=I.data;for(y=R;y--;){X=1-+y/R/5;H.fillStyle="rgb(0,"+~~(X*220)+",0)";H.fillRect(0,y+R,R*4,1)}S=0;setInterval(function(){S++;for(y=R;y--;){P=R*y;X=0.7+y/R/5;G=1/(0.2+y/R);for(x=R*4;x--;)i=y*R*16+x*4,D[i]=a[(~~(x/2/G-y)+S+P+S*3*R+~~(S/2)*K)%Z]*X,D[i+1]=D[i+2]=255*X,D[i+3]=255}I.data=D;H.putImageData(I,0,0)},50)
- Description
- Scientifically (not) very accurate cloud time-lapse simulation.
It might take a while to load. Don't be alarmed.
- Base64 encoded
TT1NYXRoO1I9MTI4O0s9UipSO1o9SypSO2M9ZG9jdW1lbnQuYm9keS5jaGlsZHJlblswXTtjLndpZHRoPVIqNDtjLmhlaWdodD1SKjI7Yy5zdHlsZS5ib3JkZXI9IjJweCBzb2xpZCAjMDAwIjtIPWMuZ2V0Q29udGV4dCgiMmQiKTthPVtdO2ZvcihpPVo7aS0tOylhW2ldPU0ucmFuZG9tKCk7Rj0zMjtDPVtdO2ZvcihpPUY7aS0tOylDW2ldPSgxLU0uY29zKGkvRipNLlBJKSkvMjtVPUY7Zm9yKGY9MjtmPDY0O2YqPTIpe1UvPTI7Zm9yKHo9MDt6PFI7eis9Zil7QT16PFItZj96K2Y6MDtmb3IoeT0wO3k8Ujt5Kz1mKXtPPXk8Ui1mP3krZjowO2Zvcih4PTA7eDxSO3grPWYpe0w9eDxSLWY/eCtmOjA7Zm9yKGk9ZjtpLS07KWZvcihqPWY7ai0tOylmb3Ioaz1mO2stLTspe1E9Q1tqKlVdO1c9Q1tpKlVdO0U9Q1trKlVdO0o9eipLK2sqSyt5KlIraipSK3graTtUPTEtVztCPXoqSztOPUEqSztZPXkqUjtWPU8qUjthW0pdPWFbSl0vMisoKChhW0IrWSt4XSpUK2FbQitZK0xdKlcpKigxLVEpKyhhW0IrVit4XSpUK2FbQitWK0xdKlcpKlEpKigxLUUpKygoYVtOK1kreF0qVCthW04rWStMXSpXKSooMS1RKSsoYVtOK1YreF0qVCthW04rVitMXSpXKSpRKSpFKS8yfX19fX1mb3IoaT1aO2ktLTspe2s9YVtpXTtrPWs+MC41PzAuNTprPDAuMz8wLjM6azthW2ldPX5+KDI1NSpNLmNvcygoayo1LTEuNSkvMipNLlBJKSl9ST1ILmdldEltYWdlRGF0YSgwLDAsUio0LFIpO0Q9SS5kYXRhO2Zvcih5PVI7eS0tOyl7WD0xLSt5L1IvNTtILmZpbGxTdHlsZT0icmdiKDAsIit+fihYKjIyMCkrIiwwKSI7SC5maWxsUmVjdCgwLHkrUixSKjQsMSl9Uz0wO3NldEludGVydmFsKGZ1bmN0aW9uKCl7UysrO2Zvcih5PVI7eS0tOyl7UD1SKnk7WD0wLjcreS9SLzU7Rz0xLygwLjIreS9SKTtmb3IoeD1SKjQ7eC0tOylpPXkqUioxNit4KjQsRFtpXT1hWyh+fih4LzIvRy15KStTK1ArUyozKlIrfn4oUy8yKSpLKSVaXSpYLERbaSsxXT1EW2krMl09MjU1KlgsRFtpKzNdPTI1NX1JLmRhdGE9RDtILnB1dEltYWdlRGF0YShJLDAsMCl9LDUwKQ==
- Original source
M = Math;
R = 128;
R2=R*R;
R3=R2*R;
canvas = document.body.children[0];
canvas.width = R*4;
canvas.height = R*2;
canvas.style.border = "2px solid #000";
cnt = canvas.getContext("2d");
ar = [];
for(i=R3;i--;)
{
ar[i] = M.random();
}
freq=32;
C=[];
for(i=freq;i--;)
C[i]=(1 - M.cos(i/freq*M.PI))/2;
cf=freq;
for(f=2;f<64;f*=2) {
cf/=2;
for(z=0;z<R;z+=f) {
zn =(z<R-f?z+f:0);
for(y=0;y<R;y+=f) {
yn =(y<R-f?y+f:0);
for(x=0;x<R;x+=f) {
xn =(x<R-f?x+f:0);
for(i=f;i--;) for(j=f;j--;) for(k=f;k--;) {
ver = C[j*cf];
hor = C[i*cf];
dee = C[k*cf];
ind = z*R2+k*R2+y*R+j*R+x+i;
tho = 1-hor;
tz1=z*R2;
tz2=zn*R2;
ty1=y*R;
ty2=yn*R;
ar[ind]=ar[ind]/2+
(((ar[tz1+ty1+x]*tho+ar[tz1+ty1+xn]*hor)*(1-ver)+
(ar[tz1+ty2+x]*tho+ar[tz1+ty2+xn]*hor)*ver)*(1-dee)+
((ar[tz2+ty1+x]*tho+ar[tz2+ty1+xn]*hor)*(1-ver)+
(ar[tz2+ty2+x]*tho+ar[tz2+ty2+xn]*hor)*ver)*dee)/2
}
}
}
}
}
for(i=R3;i--;) {
k=ar[i];
k=(k>0.5?0.5:(k<0.3?0.3:k));
ar[i]=~~(255*M.cos((k*5-1.5)/2*M.PI));
}
imdata = cnt.getImageData(0,0,R*4,R);
dta = imdata.data;
for(y=R;y--;) {
fade=1-+y/R/5;
cnt.fillStyle="rgb(0,"+~~(fade*220)+",0)";
cnt.fillRect(0,y+R,R*4, 1);
}
step = 0;
setInterval(function() {
step++;
for(y=R;y--;) {
plus=R*y;
fade=0.7+y/R/5;
fadex=1/(0.2+y/R);
for(x=R*4;x--;) {
i=y*R*16+x*4;
dta[i] =ar[(~~(x/2/fadex-y)+step+plus+step*3*R+~~(step/2)*R2)%R3]*fade;
dta[i+1] = dta[i+2] = 255*fade;
dta[i+3] = 255;
}
}
imdata.data=dta;
cnt.putImageData(imdata,0,0);
},50)