forked from chiptune/js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplasma1k.html
More file actions
1 lines (1 loc) · 895 Bytes
/
plasma1k.html
File metadata and controls
1 lines (1 loc) · 895 Bytes
1
<script>o=document;m=Math;C=m.cos;S=m.sin;R=m.round;function U(){return R(m.random()*2+1)};var n=40,x,y,w,h,pw,ph=0,p,z=m.PI/180,a=b=c=d=0,a1=a2=a3=a4=a5=a6=1,cr=cg=cb=cc=128;function s(){p=o.getElementById("p");x=p.getContext("2d");w=innerWidth;h=innerHeight;pw=R(w/n);ph=R(h/n);p.width=w;p.height=h;g();q()}function q(){for(e=0;e<n;e++){a+=C(z*e*a1)/2000,c+=S(z*(n-e)*a3)/1000;for(f=0;f<n;f++)b+=C(z*f*a2)/1000,d+=S(z*(n-f)*a4)/2000,i=e*8*S(z*(a+b)*a5),j=f*8*C(z*(c+d)*a6),k=(e*a1+f*a2)*32*S(z*((n-e)*i+(f-n)*j)*a3/720),l=(n*a4-e*a4+n*a5-f*a5)*32*S(z*(e*i+f*j)*a6/720),i=48*C(z*i)+48*C(z*j),cr=128+R(48*C(z*k)+i),cb=128+R(48*C(z*l)+i),cg=R((cr+cb)/2-i*2),x.fillStyle='rgb('+cr+','+cg+','+cb+')',x.fillRect(f*pw,e*ph,pw,ph)}setTimeout(q,20)}function g(){a1=U();a2=U();a3=U();a4=U();a5=U();a6=U()};</script><body style=margin:0;cursor:pointer onload=s()><canvas id=p onclick=g()></canvas></body>